Submit Form With Ajax And Jquery Validation October 21, 2024 Post a Comment I have form. There are two inputs:name and birthday. My code is: Solution 1: Try using the below code instead of ajaxSubmit:$.ajax({ type: "GET", url: "addEmpl.php", data: $(this).serialize(), dataType: "html"success: function(data) { $("#block").html(data); } }); CopyHope it will help you :)Solution 2: You can write like this:$().ready(function() { $("#addForm").validate({ rules:{ name:{ required: true, minlength: 2, maxlength: 10, }, }, highlight: function (element) { $(element).closest('.form-group').addClass('has-error'); }, messages:{ name:{ required: "This field is required", minlength: "Name must be at least 2 characters", maxlength: "Maximum number of characters - 10", }, }, submitHandler: function(form) { $.ajax({ url:'addEmpl.php', type:'GET', dataType: 'html', success: function(data) { $("#block").html(data); } }); returnfalse; // required to block normal submit since you used ajax } }); }); CopyHere is the fiddle http://jsfiddle.net/bhumi/bvdu94c4/Solution 3: You can try this <script> $('#submit').click(function (){ //your code here }); </script>Copy Share Post a Comment for "Submit Form With Ajax And Jquery Validation"
Post a Comment for "Submit Form With Ajax And Jquery Validation"