<script id="demo1" type="text/javascript">
jQuery(document).ready(function () {
var validator = jQuery("#login").validate({
rules: {
pwd: "required",
log: {
required: true,
email: true,
},
},
messages: {
pwd: "Please enter password",
log: {
required: "Email is required",
email: "Please enter a valid Email Address",
}
},
errorPlacement: function (error, element) {
if (element.is(":radio"))
error.appendTo(element.parent().next().next());
else if (element.is(":checkbox"))
error.appendTo(element.parent().next("span#error"));
else
error.appendTo(element.parent().next("div#error"));
//error.appendTo ('div#error').show().fadeOut(4500);
},
success: function (label) {
// set as text for IE
label.html(" ").addClass("checked");
}
});
});
</script>
I have this script to validate the form, this script runs well for my form, i want to run a function when all the fields are validated , means inputs are correct , if i call function inside success then it runs everytime when a single input is validated, but i want to call it after all the inputs are correct, please help, i am trying different ways from last one hour with no result..
below code work for me
jQuery(document).ready(function() {
var validator = jQuery("#login").validate({
rules: {
pwd: "required",
log: {
required: true,
email:true,
},
},
messages: {
pwd: "Please enter password",
log: {
required: "Email is required",
email:"Please enter a valid Email Address",
}
},
submitHandler: function(form) {
// call your function
$("#login")[0].submit();
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With