"I have a" form "with many inputs, and on the button" Submit "I call javascript, which manipulates the information and sends ajax to php File"
It is absolutely imperative that you have <form></form> tags for the jQuery Validate plugin to function properly or in general.
If you use ajax , you must put your ajax inside the submitHandler the jQuery Validate plugin . Below is my example.
"Can I add a form tag without an action URL to validate my" form "using jquery validation?"
Yes, you can remove or block action and use jQuery Validate.
See a demo: http://jsfiddle.net/NEPsc/3/
Put your ajax and return false in submitHandler and no regular submitHandler will be executed:
$(document).ready(function() { $('#myform').validate({ // initialize plugin // your rules & options, submitHandler: function(form) { // your ajax would go here return false; // blocks regular submit since you have ajax } }); });
EDIT
According to the OP comments, to use input type="button" instead of input type="submit" , you need to use a click handler. No need to have built-in JavaScript. Remove the entire onClick function.
See updated demo: http://jsfiddle.net/NEPsc/5/
Sparky
source share