I have a form within a php page. And I want to stop it’s submission with jquery for validation purposes.
$('form').submit(function(){
alert('submitting');
return false;
});
Now this works just fine, if I try to send the form to another page. But if I write the php side validation and insertion codes on the same page as the form (with form’s action=""), the page refreshes on submit and the data gets inserted in db…..any way to stop this? or do I have to use two separate pages for form and serverside validation/insertion ?
I don’t know how much it could help, but for validation I use to hook an handler on the submit button instead of the form’s submit event.
I mean that if you have in your HTML:
on your javascript you will have:
Hope this helps.