I need help, I have a code to validate the text input in a field, if the field only accept letters or numbers, it works find in IE and Netscape.
The problem is when I put characters like á, é, í, netscape is closed in that moment.
this is the code an I call the function in:
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#ffffee" OnLoad="obtenNavegador(); habilitaEV();">
I hope somebody can help me
function obtenNavegador() {
strExplorador = navigator.appName;
//Validaciones para algunas variables de inicio
nbCtrlNotiene=document.forms[0].chkNotiene.value;
var control=document.forms[0].egeneral_icrediticia;
if (control.options[control.selectedIndex].text.toUpperCase()=="NO TENGO" {
NoCreditos=true;
}
return;
}
/******************************************************************************
funcion habilitaEV
******************************************************************************/
function habilitaEV(){
if (strExplorador.indexOf("Explorer",0) == -1) {
document.captureEvents(Event.KEYDOWN);
document.onkeydown=validaTecla;
}
return;
}
/******************************************************************************
funcion validaTecla
******************************************************************************/
function validaTecla(evento) {
var bolRegreso=false;
var control=evento.target.name;
if (control=="itotal_ifinanciera" || control == "estado_ipersonal" || control == "ciudad_ipersonal" || control == "delegacion_ipersonal"
|| control == "estado_ibienes" || control == "ciudad_ibienes" || control == "delegacion_ibienes"
|| control == "estado_ilaboral" || control == "ciudad_ilaboral" || control == "delegacion_ilaboral"
|| control == "estadoa_ilaboral" || control == "ciudada_ilaboral" || control == "delegaciona_ilaboral" {
bolRegreso = false;
} else if (control == "nombre_ipersonal" || control == "nombre2_ipersonal" || control == "paterno_ipersonal" || control == "materno_ipersonal" || control == "rfca_ipersonal" {
bolRegreso = validaLetras(evento);
} else if (control == "lada_ilaboral" || control == "lada_ipersonal" || control == "telefono_ipersonal" ||
control == "tiempo_ibienes" || control == "dependientes_ipersonal" || control == "antiguedad_ilaboral" ||
control == "antiguedada_ilaboral" || control == "imensual_ifinanciera" || control == "ifijo_ifinanciera" ||
control == "itotal_ifinanciera" || control == "tcredito_icrediticia" || control == "mcredito_icrediticia" ||
control == "scredito_icrediticia" || control == "pcredito_icrediticia" || control == "auto_ibienes" ||
control == "lada_ilaboral" || control == "extension_ilaboral" || control == "telefono_ilaboral" ||
control == "anio_ipersonal" || control == "rfcb_ipersonal" || control == "anio_ipersonal"
//codigo del cambio
/*control == "numeroext_ipersonal" || control == "numeroint_ipersonal" ||
control == "numeroext_ibienes" || control == "numeroint_ibienes" ||
control == "numeroext_ilaboral" || control == "numeroint_ilaboral" ||
control == "numeroexta_ipersonal" || control == "numerointa_ipersonal" */
//termina cambio
) {
bolRegreso = validaNumeros(evento);
} else if(control == "rfcc_ipersonal"{
bolRegreso = validaLetrasNum(evento);
} else if (control == "correo_ipersonal" {
bolRegreso = validaCorreo_kp(evento);
} else if (control == "calle_ipersonal" || control == "calle_ibienes" || control == "calle_ilaboral" || control == "callea_ilaboral" ||
control == "numeroext_ipersonal" || control == "numeroint_ipersonal" ||
control == "numeroext_ibienes" || control == "numeroint_ibienes" ||
control == "numeroext_ilaboral" || control == "numeroint_ilaboral" ||
control == "numeroexta_ipersonal" || control == "numerointa_ipersonal" || control == "nombre_ilaboral" {
bolRegreso = validaCalle_kp(evento);
} else if (control == "nacimiento_ipersonal" {
bolRegreso = validaFecha_kp(evento);
} else if (control == "rfc_ipersonal" {
bolRegreso = validaRFC_kp(evento);
} else if (control == "cp_ipersonal"{
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaCP_kdown(evento);
}
} else if(control == "cp_ibienes"{
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaCP1_kdown(evento);
}
} else if(control == "cp_ilaboral"{
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaCPlab_kdown(evento);
}
} else if(control == "cpa_ilaboral" ) {
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaCPlaba_kdown(evento);
}
}
else if (control == "modelo_ibienes" {
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaModelo_kdown(evento);
}
} else {
bolRegreso = true;
}
return bolRegreso;
}
The problem is when I put characters like á, é, í, netscape is closed in that moment.
this is the code an I call the function in:
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#ffffee" OnLoad="obtenNavegador(); habilitaEV();">
I hope somebody can help me
function obtenNavegador() {
strExplorador = navigator.appName;
//Validaciones para algunas variables de inicio
nbCtrlNotiene=document.forms[0].chkNotiene.value;
var control=document.forms[0].egeneral_icrediticia;
if (control.options[control.selectedIndex].text.toUpperCase()=="NO TENGO" {
NoCreditos=true;
}
return;
}
/******************************************************************************
funcion habilitaEV
******************************************************************************/
function habilitaEV(){
if (strExplorador.indexOf("Explorer",0) == -1) {
document.captureEvents(Event.KEYDOWN);
document.onkeydown=validaTecla;
}
return;
}
/******************************************************************************
funcion validaTecla
******************************************************************************/
function validaTecla(evento) {
var bolRegreso=false;
var control=evento.target.name;
if (control=="itotal_ifinanciera" || control == "estado_ipersonal" || control == "ciudad_ipersonal" || control == "delegacion_ipersonal"
|| control == "estado_ibienes" || control == "ciudad_ibienes" || control == "delegacion_ibienes"
|| control == "estado_ilaboral" || control == "ciudad_ilaboral" || control == "delegacion_ilaboral"
|| control == "estadoa_ilaboral" || control == "ciudada_ilaboral" || control == "delegaciona_ilaboral" {
bolRegreso = false;
} else if (control == "nombre_ipersonal" || control == "nombre2_ipersonal" || control == "paterno_ipersonal" || control == "materno_ipersonal" || control == "rfca_ipersonal" {
bolRegreso = validaLetras(evento);
} else if (control == "lada_ilaboral" || control == "lada_ipersonal" || control == "telefono_ipersonal" ||
control == "tiempo_ibienes" || control == "dependientes_ipersonal" || control == "antiguedad_ilaboral" ||
control == "antiguedada_ilaboral" || control == "imensual_ifinanciera" || control == "ifijo_ifinanciera" ||
control == "itotal_ifinanciera" || control == "tcredito_icrediticia" || control == "mcredito_icrediticia" ||
control == "scredito_icrediticia" || control == "pcredito_icrediticia" || control == "auto_ibienes" ||
control == "lada_ilaboral" || control == "extension_ilaboral" || control == "telefono_ilaboral" ||
control == "anio_ipersonal" || control == "rfcb_ipersonal" || control == "anio_ipersonal"
//codigo del cambio
/*control == "numeroext_ipersonal" || control == "numeroint_ipersonal" ||
control == "numeroext_ibienes" || control == "numeroint_ibienes" ||
control == "numeroext_ilaboral" || control == "numeroint_ilaboral" ||
control == "numeroexta_ipersonal" || control == "numerointa_ipersonal" */
//termina cambio
) {
bolRegreso = validaNumeros(evento);
} else if(control == "rfcc_ipersonal"{
bolRegreso = validaLetrasNum(evento);
} else if (control == "correo_ipersonal" {
bolRegreso = validaCorreo_kp(evento);
} else if (control == "calle_ipersonal" || control == "calle_ibienes" || control == "calle_ilaboral" || control == "callea_ilaboral" ||
control == "numeroext_ipersonal" || control == "numeroint_ipersonal" ||
control == "numeroext_ibienes" || control == "numeroint_ibienes" ||
control == "numeroext_ilaboral" || control == "numeroint_ilaboral" ||
control == "numeroexta_ipersonal" || control == "numerointa_ipersonal" || control == "nombre_ilaboral" {
bolRegreso = validaCalle_kp(evento);
} else if (control == "nacimiento_ipersonal" {
bolRegreso = validaFecha_kp(evento);
} else if (control == "rfc_ipersonal" {
bolRegreso = validaRFC_kp(evento);
} else if (control == "cp_ipersonal"{
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaCP_kdown(evento);
}
} else if(control == "cp_ibienes"{
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaCP1_kdown(evento);
}
} else if(control == "cp_ilaboral"{
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaCPlab_kdown(evento);
}
} else if(control == "cpa_ilaboral" ) {
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaCPlaba_kdown(evento);
}
}
else if (control == "modelo_ibienes" {
bolRegreso = validaNumeros(evento);
//Tiene que validar otras cosas
if (bolRegreso) {
validaModelo_kdown(evento);
}
} else {
bolRegreso = true;
}
return bolRegreso;
}