1 2// ========================================================= 3// Validation/Submission/Response for Grief 365 Widget 4// ========================================================= 5 6$(document).ready(function(){ 7 8 9 // Add the permissive Phone Regex, stolen from: 10 // http://saikiran78.wordpress.com/2011/04/20/phone-number-validation-using-jquery/ 11 // This sets the tag that calls this regex in the validator, and a default error message. 12 // see sf_phone below for usage 13 14 jq162.validator.addMethod("permissivePhone", 15 function (value, element) { 16 return this.optional(element)||/^((\+)?[1-9]{1,2})?([-\s\.])?((\(\d{1,4}\))|\d{1,4})(([-\s\.])?[0-9]{1,12}){1,2}$/.test(value); 17 }, "Please specify a valid phone number" 18 ); 19 20 21 jq162("#contactUsForm").validate({ 22 rules:{ 23 contactEmail:{ 24 required: { 25 depends:function(){ 26 $(this).val($.trim($(this).val())); 27 return true; 28 } 29 }, 30 email: true 31 }, 32 contactPhone:{ 33 permissivePhone:true 34 }, 35 contactName: "required", 36 contactCity: "required" 37 }, 38 messages:{ 39 contactName: "Required!", 40 contactCity: "Required!", 41 contactEmail:{ 42 required: "Required!", 43 email: "Invalid!" 44 }, 45 contactPhone:{ 46 permissivePhone: "Invalid!" 47 } 48 }, 49 errorPlacement:function(error, element) { 50 error.insertAfter(element.siblings("label")); 51 error.css('float','right'); 52 //error.css('padding-left','10px'); 53 }, 54 55 submitHandler: function(form) { 56 document.getElementById("contactUsFormSubmit").disabled = true; 57 jq162.post('./include/websitewidgets/actions/cloneFormHandler.php', 58 $("#contactUsForm").serialize() + "&formName=contactUsForm", 59 function(data) { 60 alert(data); 61 } 62 ); 63 } 64 }); 65 66 jq162("#contactUsFormClear").click(function() { 67 document.getElementById("contactUsFormSubmit").disabled = false; 68 jq162("#contactUsForm").validate().resetForm(); 69 }); 70}); 71 72 73
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.