Every line of 'jquery regex validation' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
18 public validate(value: any): boolean { 19 const regexp = new RegExp(this.pattern); 20 this.isValid = regexp.test(value); 21 return this.isValid; 22 }
55 async function validateRegEx(value) { 56 if (this.settings && this.settings.PASSWORD_USE_CUSTOM_REGEX) { 57 try { 58 // try and create a regex - a (caught) error will mean an invalid regex 59 RegExp(value); 60 } catch (e) { 61 throw new Error('This RegEx is not valid'); 62 } 63 } 64 return true; 65 }
100 function validate() { 101 var $this = $(this); 102 var $parentElem = $this.closest(".brz-form__item"); 103 var value = $this.val(); 104 var data = $this.data(); 105 var type = data.type; 106 var result = true; 107 var isRequired = $this.prop("required"); 108 var pattern = $this.attr("pattern"); 109 110 $parentElem.removeClass( 111 "brz-form__item--error brz-form__item--error-pattern brz-form__item--error-required" 112 ); 113 114 if (type === "Number") { 115 if (isRequired && !new RegExp(pattern).test(value)) { 116 $parentElem.addClass( 117 "brz-form__item--error brz-form__item--error-pattern" 118 ); 119 result = false; 120 } 121 } else if (!new RegExp(pattern).test(value)) { 122 $parentElem.addClass( 123 "brz-form__item--error brz-form__item--error-pattern" 124 ); 125 result = false; 126 } 127 128 if (isRequired && !value.length) { 129 $parentElem.addClass( 130 "brz-form__item--error brz-form__item--error-required" 131 ); 132 result = false; 133 } 134 135 return result; 136 }
167 function validator(val: string): boolean { 168 if (val.trim() === '') { 169 return false; 170 } 171 return true; 172 }
11 setValidity (value) { 12 if (this.pattern) { 13 const regexp = new RegExp(this.pattern); 14 this.valid = regexp.test(value); 15 } else if (this.validator) { 16 this.valid = this.validator({ modelValue: value }); 17 } 18 19 this.password.updateValidity(this.name, this.valid); 20 }
5 function validator(value) { 6 if (typeof value === 'string' && value.length > 0) { 7 return true; 8 } else { 9 return false; 10 } 11 }
54 function defaultValidator(value, regex) { 55 return regex.test(value); 56 }
55 static validator(value) { 56 return /^([+-]?[\d]+(\.\d+)?|[+-]?\.\d+)$/.test(value); 57 }
125 function regex(str) { 126 try { 127 new RegExp(str); 128 return true; 129 } catch(e) { 130 return false; 131 } 132 }
152 var inputValidation = function inputValidation() { 153 if (string.match(onlyNumbers) && string.match(separateNums).length === 4 && string.match(bigNumber) == null) { 154 paddingCorrect = true; 155 lastLayer.name = string.replace(whiteSpace, " "); 156 padding = lastLayer.name.split(" "); 157 } 158 159 if (string.match(onlyNumbers) && string.match(separateNums).length === 1 && string.match(bigNumber) == null) { 160 paddingCorrect = true; 161 var firstNum = string.match(separateNums)[0]; 162 lastLayer.name = firstNum + " " + firstNum + " " + firstNum + " " + firstNum; 163 padding = lastLayer.name.split(" "); 164 } 165 166 if (string.match(onlyNumbers) && string.match(separateNums).length === 2 && string.match(bigNumber) == null) { 167 paddingCorrect = true; 168 var firstNum = string.match(separateNums)[0]; 169 var secondNum = string.match(separateNums)[1]; 170 lastLayer.name = firstNum + " " + secondNum + " " + firstNum + " " + secondNum; 171 padding = lastLayer.name.split(" "); 172 } 173 174 if (string.match(onlyNumbers) && string.match(separateNums).length === 3 && string.match(bigNumber) == null) { 175 paddingCorrect = true; 176 var firstNum = string.match(separateNums)[0]; 177 var secondNum = string.match(separateNums)[1]; 178 var thirdNum = string.match(separateNums)[2]; 179 lastLayer.name = firstNum + " " + secondNum + " " + thirdNum + " " + secondNum; 180 padding = lastLayer.name.split(" "); 181 } 182 183 if (string.match(bigNumber) != null) { 184 message = "Maximum of 3 digits for each padding"; 185 } 186 187 if (string.match(onlyNumbers) && string.match(separateNums).length > 4) { 188 message = "Enter 4 numbers or less"; 189 } 190 191 if (string.match(otherCharacters)) { 192 message = "Enter numbers only"; 193 } 194 195 if (string === "null") { 196 paddingCorrect = true; 197 } 198 };