1// BEG of /plugins/formwizard/formwizard.form_validation_include.js \\ 2function RZtrim(tmpStr) 3{ 4 while(tmpStr.substring(0,1) == " ") 5 tmpStr = tmpStr.substring(1, tmpStr.length); 6 while(tmpStr.substring(tmpStr.length-1,tmpStr.length) == " ") 7 tmpStr = tmpStr.substring(0, tmpStr.length - 1); 8 return tmpStr; 9} 10function RZisNumeric(strNum) 11{ 12 for (var n = strNum.length - 1; n >= 0; n--) 13 { 14 var cDigit = strNum.charAt (n); 15 if (!RZisDigit (cDigit)) return false; 16 } 17 return true; 18} 19function RZisDigit(c) 20{ 21 var strAllowed = "1234567890"; 22 return (strAllowed.indexOf (c) != -1); 23} 24function RZisDecimal(strNum) 25{ 26 var countDot = 0; 27 for (var n = strNum.length - 1; n >= 0; n--) 28 { 29 var cDigit = strNum.charAt (n); 30 if (!RZisDigit(cDigit) && cDigit != '.' ) return false; 31 if( cDigit == '.' ) 32 countDot++; 33 if( countDot > 1 ) return false; 34 } 35 return true; 36} 37function RZisValidDate(day) 38{ 39 var date=0; 40 var month=0; 41 var year = 0; 42 var tmp=""; 43 var f = day.indexOf("/"); 44 45 if (f<=0) return false; 46 47 month = day.substring(0,f); 48 tmp = day.substring(f+1, day.length); 49 f = tmp.indexOf("/"); 50 51 if (f<=0) return false; 52 53 date = tmp.substring(0,f); 54 year = tmp.substring(f+1, tmp.length); 55 56 if( false == RZisNumeric(date) || false == RZisNumeric(month) || false == RZisNumeric(year) ) return false; 57 if (month > 12) return false; 58 if (date > 31) return false; 59 if (year.length != 4) return false; 60 if( ((month==4)||(month==6)||(month==9)||(month==11))&& (date >30) ) return false; 61 62 if(month==2) 63 { 64 if(year%4 == 0) 65 { 66 if(date>29) return false; 67 } 68 else if(date>28) 69 return false; 70 } 71 return true; 72} 73function rzValidateEmail(email) { 74 var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 75 return re.test(String(email).toLowerCase()); 76} 77function emailCheck (emailStr) 78{ 79 var emails = emailStr.split(";"); 80 for (var i = 0; i < emails.length; i++) { 81 if (!rzValidateEmail(emails[i])) { 82 return "Email is not valid"; 83 } 84 } 85 86 return ''; 87} 88function validate(ev) 89{ 90 if (ev === undefined) { ev = { target: document.querySelector("#formwizziwmorf") } } 91 var obj = ev.target; 92 var isNewFormWiz = obj.classList.contains("formwiznew"); 93 var radioNamesChecked = {}; 94 var emailTo = []; 95 for (var i=0;i<obj.length;i++) 96 { 97 var childNode = obj[i]; 98 var id = childNode.id; 99 var tagName = ''; 100 var type = ''; 101 102 if (childNode.tagName) { 103 tagName = childNode.tagName.toUpperCase(); 104 } 105 106 if (childNode.type) { 107 type = childNode.type.toUpperCase(); 108 } 109 110 if (tagName === "TEXTAREA" && childNode.value) { 111 childNode.value = childNode.value.replace(/\n/gm,'<br>'); 112 } 113 114 //----- If input type and is a radio button with an 'other' field 115 if (tagName === "INPUT" && (type === "RADIO" || type === "CHECKBOX")) { 116 var otherSuffix = "-other"; 117 if (childNode.checked === true && childNode.id.lastIndexOf(otherSuffix) === (childNode.id.length-(otherSuffix.length))) { 118 var textField = obj.querySelector("#"+childNode.id+"-value"); 119 if (textField) { 120 childNode.value = textField.value; 121 } 122 } 123 } 124 125 //----- If select type and selected value and has data-emails-field, override action 126 if (tagName === "SELECT") { 127 if (childNode.attributes["data-emails-field"] && childNode.attributes["data-emails-field"].value == "true") { 128 var selectedIndex = childNode.selectedIndex; 129 if (selectedIndex > -1) { 130 for (var optInd = selectedIndex; optInd < childNode.options.length; optInd++) { 131 var optionElem = childNode.options[optInd]; 132 if (optionElem.selected && optionElem.value.trim() !== "") { 133 emailTo.push(optionElem.value.trim()); 134 } 135 } 136 } 137 childNode.disabled = true; 138 } 139 } 140 } // end for all childNode processing 141 142 // If emailTo is not empty we should override the action 143 if (emailTo.length) { 144 if(obj.action.indexOf("?") != -1) 145 obj.action += '&emailTo=' + emailTo.join(","); 146 else 147 obj.action += '?emailTo=' + emailTo.join(","); 148 } 149 150 var submits = obj.querySelectorAll("button[type='submit'], input[type='submit']"); 151 for (var i = 0; i < submits.length; i++) { 152 submits[i].disabled = "disabled"; 153 } 154 155 return true; 156} // end validate 157 158// convert <br> back to \n 159function textareaSetup() 160{ 161 var forms = document.querySelectorAll("#formwizziwmorf, .formwizziwmorf"); 162 for (var f = 0; f < forms.length; f++) { 163 var obj = forms[f]; 164 // new form 165 if (obj.classList.contains("formwiznew")) { 166 obj.onsubmit = function(e) { return validate(e); } 167 168 if (obj.querySelectorAll(".g-recaptcha").length == 1) { 169 var con = document.createElement("div"); 170 con.style = "overflow:hidden;width:1px;height:1px;"; 171 var elem = document.createElement("input"); 172 elem.type = "date"; 173 elem.name = "date-16436463872412"; 174 elem.id = "date-16436463872412"; 175 elem.tabIndex = "-1"; 176 elem.autocomplete="off"; 177 con.appendChild(elem); 178 obj.insertBefore(con, obj.querySelector(".g-recaptcha")); 179 } 180 } 181 182 for (var i = 0; i < obj.length; i++) { 183 var childNode = obj[i]; 184 if (!childNode.tagName) continue; 185 186 var tagName = childNode.tagName.toUpperCase(); 187 188 if (tagName === "TEXTAREA" && childNode.value) { 189 childNode.value = childNode.value.replace(/<br>/mg,'\n'); 190 } 191 } 192 193 var checkboxGroups = obj.querySelectorAll(".formbuilder-checkbox-group"); 194 for (var i = 0; i < checkboxGroups.length; i++) { 195 var checkboxes = checkboxGroups[i].querySelectorAll("input[type=checkbox]:required"); 196 if (checkboxes.length) { 197 for (var e = 0; e < checkboxes.length; e++) { 198 199 checkboxes[e].addEventListener("change", function() { 200 var otherSuffix = "-other"; // Handle the presence of an "other" field and mark required if checkbox is checked. 201 var similar = document.querySelectorAll("[name="+this.name.replace(/([\[\]])
201/g,"\\$1")+"], [id="+this.name.replace(/\[\]/g,"")+otherSuffix+"-value]"); // Escape reserved characters [] in name. 7/23/2024 Also select the OTHER box to unrequire it if necessary. 202 var hasChecked = false; 203 for (var s = 0; s < similar.length; s++) { 204 if (similar[s].checked) { hasChecked = true; } // Check if any of the checkboxes are selected 205 } 206 for (var s = 0; s < similar.length; s++) { 207 similar[s].required = !hasChecked; 208 } 209 210 if (this.id.lastIndexOf(otherSuffix) === (this.id.length-(otherSuffix.length))) { 211 var textField = this.parentElement.querySelector("#"+this.id+"-value"); 212 if (textField) { 213 textField.required = this.checked; 214 } 215 } 216 217 }); 218 219 } 220 } 221 } 222 } 223} 224if (window.addEventListener) addEventListener('load', textareaSetup, false); 225else if (window.attachEvent) attachEvent("onload", textareaSetup); 226// END of /plugins/formwizard/formwizard.form_validation_include.js //
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.