1$(document).ready(function () { 2 validatecontactusform(); 3}); 4 5var errorMsg = document.querySelector(".error-msg"), 6validMsg = document.querySelector(".valid-msg"); 7 8function validatecontactusform() { 9 $("#contactusform").validate({ 10 rules: { 11 name:{ 12 maxlength: 50, 13 letterspace: true, 14 }, 15 email:{ 16 required: true, 17 minlength: 8, 18 maxlength: 256, 19 nospace: true, 20 email: true, 21 emailvalid: true, 22 }, 23 subject: { 24 required: true, 25 }, 26 message: { 27 required: true, 28 }, 29 30 }, 31 messages: { 32 name:{ 33 required: "Enter the Name", 34 maxlength: "Name must not exceed 50 characters", 35 letterspace: "Please enter only alphabets" 36 }, 37 email:{ 38 required: "Enter the email-id", 39 minlength: "Email address must have minimum 8 characters", 40 maxlength: "Email address must not exceed more than 256 characters", 41 nospace: "No space allowed", 42 email: "Enter a valid email id", 43 emailvalid: "Email address has invalid characters", 44 }, 45 subject: { 46 required: "Enter the Subject", 47 }, 48 message:{ 49 required: "Enter the Message", 50 } 51 }, 52 onfocusout: function (element) { 53 this.element(element); 54 }, 55 submitHandler: function (form) { 56 // form.submit(); 57 } 58 }); 59 $.validator.setDefaults({ 60 debug: true, 61 success: 'valid' 62 }); 63} 64 65 66function getFormData($form){ 67 var unindexed_array = $form.serializeArray(); 68 var indexed_array = {}; 69 70 $.map(unindexed_array, function(n, i){ 71 indexed_array[n['name']] = n['value']; 72 }); 73 74 return indexed_array; 75} 76 77$(document).on('click', '#contactus_btn', function (e) { 78 if (!e.detail || e.detail == 1) { 79 var _this = $(this); 80 var contactusform = $("#contactusform"); 81 console.log(contactusform) 82 if (contactusform.valid()) { 83 var $form = contactusform 84 var data = getFormData($form); 85 $.ajax({ 86 url:'/contactus_mail/', 87 type:'POST', 88 data:JSON.stringify(data), 89 beforeSend:function(xhr){ 90 xhr.setRequestHeader("X-CSRFToken",csrf_token); 91 toggleSpinner(_this, _this, true); 92 }, 93 success:function(resp){ 94 if(resp.code >=200 && resp.code <=299){ 95 ukalert("success", resp.message); 96 formreset("contactusform") 97 toggleSpinner(_this, _this, false); 98 } 99 }, 100 error:function(xhr, status, exception){ 101 parseErrors(xhr.responseText); 102 toggleSpinner(_this, _this, false); 103 } 104 }) 105 } 106 else{ 107 formvalidateerror("contactusform") 108 } 109 } 110});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.