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