Validar input cuando se pulsa enter
Publicado por Oscar Medina (8 intervenciones) el 15/10/2001 19:54:55
Tengo un problema al querer validar un input type="text", tengo este codigo (resumido):
function checkInformation(forma) {
var bError = false;
if (isNaN(forma.txtNip.value)) {
alert("Nip debe de ser numerico.");
forma.txtNip.focus();
bError = true;
return;
}
if (!bError) {
forma.submit();
}
return;
}
...
<form name="frmPreSol" method="post" action="movperi2.asp">
NIP:<input name="txtNip" type="password">
<a href="javascript:checkInformation(document.frmPreSol)"> Procesar</a>
</form>
mi problema es que no deseo que en ese campo se introduzcan caracteres, si le doy ckick al link Procesar la validacion toma efecto y me indica que el Nip debe ser numerico, mas sin embargo, si me pocisiono en el campo, tecleo el Nip y enseguida pulso enter el codigo de javascript no llama la funcion checkInformation() y por lo tanto no ejecuta ninguna validacion
espero me puedan ayudar
de antemano gracias
Lic. Oscar Medina
function checkInformation(forma) {
var bError = false;
if (isNaN(forma.txtNip.value)) {
alert("Nip debe de ser numerico.");
forma.txtNip.focus();
bError = true;
return;
}
if (!bError) {
forma.submit();
}
return;
}
...
<form name="frmPreSol" method="post" action="movperi2.asp">
NIP:<input name="txtNip" type="password">
<a href="javascript:checkInformation(document.frmPreSol)"> Procesar</a>
</form>
mi problema es que no deseo que en ese campo se introduzcan caracteres, si le doy ckick al link Procesar la validacion toma efecto y me indica que el Nip debe ser numerico, mas sin embargo, si me pocisiono en el campo, tecleo el Nip y enseguida pulso enter el codigo de javascript no llama la funcion checkInformation() y por lo tanto no ejecuta ninguna validacion
espero me puedan ayudar
de antemano gracias
Lic. Oscar Medina
Valora esta pregunta


0