This is part of jquery.form plugin and autocomplete, i need the user complete his city in the form "city, state, country", at this point this is ok, but if the user put anything that dont exist i should parse his string and split the value (in ciudad_auto input) to get the vars ciudad, provincia and pais, i set the values i get in a hidden fields. When this is complete the form is submit, but with null values, and the values are filled!

I cant undestand i and wasting all my time trying to fix this

thx


function validate(formData, jqForm, options) {
   var form = jqForm[0];

if ( ! form.ciudad.value || ! form.provincia.value || ! form.pais.value ) {
       var row = new Array();
       row = form.ciudad_auto.value.split(",");
       if ( row.length == 3 )
       {
           $("#ciudad").val(row[0]);
           $("#provincia").val(row[1]);
           $("#pais").val([2]);
       }
       else
       {
alert("Por favor escriba donde vive de la siguiente forma separado por una coma: 'ciudad, provincia, país'");
           return false;
       }
   }

if (! form.nombre.value || ! form.ciudad.value || ! form.titulo.value || ! form.firma.value || ! form.email.value) { alert('Debería completar los campos marcados con un asterísco (*).');
       return false;
   }

   alert("Muchas gracias!");
   //window.location = "libro_visitas.htm"
}

Reply via email to