no, there isn't any error! I did removed return false; from onSubmit handler , but nothing new !! the form proceed to submit without STOP ! the alert appears & when I click ok, it goes to the next page with no stop !
Thanks for your time, Mahmoud Abdel-Fattah On Feb 26, 2:12 am, James <james.gp....@gmail.com> wrote: > Are there any errors that returned? Usually it's a JS error the > cripples the code and makes it submit regardless. > What happens if validate_form() only contains "return false"? Does it > not submit? > > You should probably remove the "return false" on the onsubmit handler > or else it'll never submit since you don't have anything in your JS to > tell it to submit (eg. form.submit()). > > On Feb 25, 1:40 pm, "Mahmoud M. Abdel-Fattah" <engm...@gmail.com> > wrote: > > > I'm using .each () for form validation , with dynamic form elements, > > and here's the JS function : > > > function validate_form() { > > $("select[id^='products']").each(function(){ > > if(this.value == "0") { > > alert('MESSAGE1'); > > document.getElementById(this.id).focus(); > > return false; > > } else if(this.value==14 && document.getElementById > > ('address').value == "") { > > alert('MESSAGE2'); > > document.getElementById('address').focus(); > > return false; > > } > > }); > > > $("input[id^='amount']").each(function(){ > > if(this.value == "" || this.value == "0" || this.value != > > parseInt(this.value)) { > > alert('MESSAGE3'); > > document.getElementById(this.id).focus(); > > return false; > > } > > }); > > > } > > > and I add to the form tag : > > onsubmit="validate_form(); return false;" > > > When I submit the form, the validation works fine BUT it doesn't STOP, > > it continue to submit the data ALTHOUGH there's return false; !! > > > So, what's the problem ?? > > > Thanks for your time, > > Mahmoud M. Abdel-Fattah