1// Enable jQuery validator on any form with class="validate" which hasn't already been set up 2// Modifications made for bootstrap 4 noted below 3function enableValidator() { 4 var config = { 5 ignore: ":hidden", 6 // For popover-style validation errors that go nicely with bootstrap 7 showErrors: function(errorMap, errorList) { 8 window._dbgErrorMap = errorMap; 9 window._dbgErrorList = errorList; 10 $.each(this.successList, function(index, value) { 11 return $(value).popover("hide"); 12 }); 13 14 for ( i = 0; this.errorList[i]; i++ ) { 15 var error = this.errorList[i]; 16 if ( this.settings.highlight ) { 17 this.settings.highlight.call( this, error.element, this.settings.errorClass, this.settings.validClass ); 18 } 19 } 20 if ( this.settings.unhighlight ) { 21 for ( i = 0, elements = this.validElements(); elements[i]; i++ ) { 22 this.settings.unhighlight.call( this, elements[i], this.settings.errorClass, this.settings.validClass ); 23 } 24 } 25 26 // Only warn about one error at a time, to avoid popup explosion 27 //errorList = errorList.slice(0, 1); 28 $.each(errorList, function(index, value) { 29 var _popover; 30 if ($(value.element).is(':hidden')) { 31 value.element = $(value.element).parent(); 32 } 33 _popover = $(value.element).popover({ 34 trigger: "manual", 35 placement: "bottom", 36 content: value.message, 37 template: "<div class=\"popover\" role=\"tooltip\"><div class=\"arrow\"></div><div class=\"popover-body\"></div></div>", //updated template for bootstrap4 38 }); 39 // _popover.data("bs.popover").options.content = value.message; //js error for bootstrap 4, not vital 40 $(value.element).popover("show"); 41 }); 42 }, 43 invalidHandler: function(e) { 44 if (typeof enableSubmit == 'function') { 45 enableSubmit("Submit Order"); 46 } else { //if this is not the orders page 47 //enable all submits 48 $(':submit').removeAttr("disabled"); 49 } 50 return true; 51 }, 52 submitHandler: function(form, e) { 53 if (typeof disableSubmit == 'function') { 54 disableSubmit('Sending...'); 55 } else { //if this is not the orders page 56 //disable all submits 57 $(':submit').prop("disabled", true); 58 } 59 return true; 60 }, 61 }; 62 63 $.extend($.validator.messages, { 64 url: 'Please enter a valid URL using this format: https://domain.com' 65 }); 66 67 $("form.validate").validate(config); 68} 69 70$(document).ready(function() { 71 // Enable jquery validator for forms which request it (class="validate") 72 enableValidator(); 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.