hola a todos, el siguiente codigo tiene algun error, o varios, pero no lo encuentro.....
no se si alguien me da una mano parap buscarlo....
valida perfectamente hasta piso....
Código:
<script type="text/javascript">
function validar(form1) {
/*VARIABLES*/
var checkOKlet = "1234567890ABCEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚabcdefghijklmnñopqrstuvwxyzáéíóú" ;
var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZÁÉÍÓÚ " + "abcdefghijklmnñopqrstuvwxyzáéíóú ";
var checkOKphone = "1234567890-" ;
var checkOKnum = "1234567890"
var allValid = true;
/*BARRIO*/
barrio = document.getElementById("barrio");
indice = barrio.selectedIndex;
barrio = barrio.options[indice].value;
/*TYPE*/
type = document.getElementById("type");
indice = type.selectedIndex;
type = type.options[indice].value;
/*DORMITORIOS*/
room = document.getElementById("room");
indice = room.selectedIndex;
room = room.options[indice].value;
/*ESTADO*/
estado = document.getElementById("estado");
indice = estado.selectedIndex;
estado = estado.options[indice].value;
/*UWORD*/
var uword = hex_md5(document.getElementById('uword').value)
if(barrio == "seleccione una opcion"){
alert('Debe elegir un Barrio');
form1.barrio.focus();return (false);}
if(type == "seleccione una opcion"){
alert('Debe seleccinar el tipo de propiedad');
form1.type.focus();return (false);}
if(room == "seleccione una opcion"){
alert('Debe indicar la cantidad de dormitorios');
form1.room.focus();return (false);}
if(estado == "seleccione una opcion"){
alert('Debe indicar el estado de su propiedad');
form1.estado.focus();return (false);}
if (form1.calle.value.length < 3) {
alert('Debe ingrasar la calle donde se ubica su propiedad');
form1.calle.focus();return (false);}
if ((form1.altura.value.length < 3)||isNaN(form1.altura.value)){
alert('Debe iingresar un altura valida');
form1.altura.focus();return (false);}
if(type == "Departamento"){
/*PISO*/
if ((form1.piso.value.length < 1)||isNaN(form1.piso.value)){
alert('Inserte el piso de su departamento');
form1.piso.focus(); return (false);}
/*DEPARTAMENTO*/
if (form1.departamento.value.length = 0) {
alert('Inserte el numero o letra de departamento')
form1.departamento.focus(); return (false);}
var checkStr = form1.departamento.value;
for (i = 0; i < checkStr.length; i++) {ch = checkStr.charAt(i);
for (j = 0; j < checkOKlet.length; j++)
if (ch == checkOKlet.charAt(j))
break;
if (j == checkOKlet.length) {
allValid = false;
break;}}
if (!allValid) {
alert('Inserte el numero o letra de departamento');
form1.departamento.focus();
return (false);}
}
/*MESSAGE*/
if (form1.message.value.length < 7) {
alert('Debe ingrasar algún comentario');
form1.message.focus();
return (false);}
/*NAME*/
if (form1.name.value.length < 2) {
alert('Inserte el nombre')
form1.name.focus();
return (false);}
var checkStr = form1.name.value;
for (i = 0; i < checkStr.length; i++) {ch = checkStr.charAt(i);
for (j = 0; j < checkOK.length; j++)
if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length) {
allValid = false;
break;}}
if (!allValid) {
alert('inserte el nombre');
form1.name.focus();
return (false);}
/*PHONE*/
if (form1.phone.value.length < 8) {
alert('Inserte un numero de telefono valido')
form1.phone.focus();
return (false);}
var checkStr = form1.phone.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++) {ch = checkStr.charAt(i);
for (j = 0; j < checkOKnum.length; j++)
if (ch == checkOKphone.charAt(j))
break;
if (j == checkOKphone.length) {
allValid = false;
break;}}
if (!allValid) {
alert('Inserte un numero de telefono valido');
form1.phone.focus();
return (false);}
/*CEL*/
if (form1.cel.value.length < 8) {
alert('Inserte un numero de celular valido')
form1.phone.focus();
return (false);}
var checkStr = form1.cel.value;
var allValid = true;
for (i = 0; i < checkStr.length; i++) {ch = checkStr.charAt(i);
for (j = 0; j < checkOKphone.length; j++)
if (ch == checkOKphone.charAt(j))
break;
if (j == checkOKphone.length) {
allValid = false;
break;}}
if (!allValid) {
alert('Inserte un numero de telefono valido');
form1.cel.focus();
return (false);}
/*EMAIL*/
if ((form1.email.value.indexOf ('@', 0) == -1)||(form1.email.value.length < 9) || form1.email.value.indexOf ('.', 0)== -1 ){
alert('inserte el email');
form1.email.focus();return (false);}
/*UWORD*/
if (uword==cword[anum-1]) {
return true;}
else {
alert('inserte el código de la imagen');
document.getElementById('uword').focus();
return (false);}
return (true);
}
<script>