Reputation: 32321
On Click of Submit button only , i want to validate the form . but this is also getting called on click of Cancel button also ??
this is my code
jQuery(document).ready(function()
{
$('#pacinsertform').validate(
{
rules:
{
pacname:
{
required: true
}
},
messages:
{
pacname:
{
required: "NAME required",
}
},
highlight: function(element)
{
$(element).parent().addClass('error')
},
unhighlight: function(element)
{
$(element).parent().removeClass('error')
},
submitHandler: function(event, validator)
{
if ($("#pacinsertform").valid())
{
ajaxInsertPac();
return false;
}
}
});
});
function ajaxInsertPac()
{
alert('ajax call heer');
return false;
}
this is my fiddle
http://jsfiddle.net/Luf0ks9b/32/
Could you please tell me how to resolve this issue , thanks in advance .
Upvotes: 0
Views: 39
Reputation: 529
add this will fix the issue
$(".pacinsertcancel").click(function(e){
e.preventDefault();
});
JSFiddle link: http://jsfiddle.net/umarmw/Luf0ks9b/33/
Upvotes: 1