javascript - jquery validations not woking when ajax call is there -
i have js code validating form using jquery validations. , after calling ajax.
$('.form').validate({ rules: { ---- } }); $('#submit').click(function() { $.ajax(url,{ data:data, success:onsuccess, error:onerror, type:post }); return false; });
onsuccess , onerror simple functions. url predefined
but code not entering validations , directly calling ajax whatever might case.
you should not bind click
event on submit button. should place function on submithandler
option of jquery validation. this
$('.form').validate({ rules: { ---- }, submithandler: function(form){ //your code here.. } });
here's jquery validation docs better understand.
Comments
Post a Comment