prevent form submission with jquery when error is present?
-
Hello
Am using jquery codes directly in the form’s editor, but when using the event.preventDefault() method on a custom error check, the form still submits.Is there any other way to prevent the form from submitting when an error is present on the form?
sample code
‘
$(“#form-id-here”).submit(function(e) {
s= $(‘#datefield’).val();
var dateFormat = /^([0-9]{2})\/([0-9]{2})\/([0-9]{4})$/;
if(!dateFormat.test(s)){
alert(“wrong date”);
e.preventDefault();
return false;
}
});
‘
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘prevent form submission with jquery when error is present?’ is closed to new replies.