Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#FORM_NAME").validate({
- errorClass: 'error_text',
- errorElement: 'span',
- highlight: function(element, errorClass, validClass) {
- $(element).parents("span").addClass(errorClass);
- },
- errorPlacement: function(error, element) {
- error.insertAfter(element);
- element.focus(); // <- this line is causing your whole problem
- },
- rules: {
- "mobile": {
- required: true,
- digits: true,
- minlength: 10,
- maxlength: 10
- },
- },
- messages: {
- "mobile": {
- required: "Mobile No is Required.",
- digits: "Please Enter Digits, Not Characters."
- },
- }
- });
- var validate = $("#FORM_NAME").valid();
- if (validate == true) {
- var formData = new FormData($('#FORM_NAME')[0]);
- formData.append('lang', lang);
- ajaxCall = $.ajax({
- url: 'SITE_URL',
- type: 'POST',
- data: formData,
- cache: false,
- contentType: false,
- processData: false,
- success: function(data) {
- var res = JSON.parse(data);
- if(result.type == 'success'){
- //Message
- alert(result.message);
- // $('#FORM_NAME').trigger("reset");
- }else{
- //Message
- alert(result.message);
- }
- },
- statusCode: {
- 404: function() {
- alert("page not found");
- },
- 403: function() {
- alert("Forbidden");
- },
- 500: function() {
- alert("Internal Server Error");
- }
- }
- });
- }
Add Comment
Please, Sign In to add comment