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