1(function($) { 2 $.fn.validationEngineLanguage = function() {}; 3 $.validationEngineLanguage = { 4 newLang: function() { 5 $.validationEngineLanguage.allRules = { 6 "required": { 7 // Add your regex rules here, you can take telephone as an example 8 "regex": "none", 9 "alertText": "* This field is required", 10 "alertTextCheckboxMultiple": "* Please select an option", 11 "alertTextCheckboxe": "* This checkbox is required", 12 "alertTextDateRange": "* Both date range fields are required" 13 }, 14 "requiredInFunction": { 15 "func": function(field, rules, i, options) { 16 return (field.val() == "test") ? true : false; 17 }, 18 "alertText": "* Field must equal test" 19 }, 20 restrictPO: { 21 regex: /^(?!(?:.*\bPO\b))(?!(?:.*\bpost\s*n\b|post\s*number|po\s*box|Postal\s*Office|post\s*office|post\s*box|Po\s*box|box|Pobox)\b|.*\bP\.?O\.?\b)(?!.*\bbox\d+\b).*$/gim, 22 alertText: "Sorry, we cannot ship to PO Boxes.", 23 }, 24 "dateRange": { 25 "regex": "none", 26 "alertText": "* Invalid ", 27 "alertText2": "Date Range" 28 }, 29 "dateTimeRange": { 30 "regex": "none", 31 "alertText": "* Invalid ", 32 "alertText2": "Date Time Range" 33 }, 34 "minSize": { 35 "regex": "none", 36 "alertText": "* Minimum ", 37 "alertText2": " characters required" 38 }, 39 "maxSize": { 40 "regex": "none", 41 "alertText": "* Maximum ", 42 "alertText2": " characters allowed" 43 }, 44 "groupRequired": { 45 "regex": "none", 46 "alertText": "* You must fill one of the following fields", 47 "alertTextCheckboxMultiple": "* Please select an option", 48 "alertTextCheckboxe": "* This checkbox is required" 49 }, 50 "min": { 51 "regex": "none", 52 "alertText": "* Minimum value is " 53 }, 54 "max": { 55 "regex": "none", 56 "alertText": "* Maximum value is " 57 }, 58 "past": { 59 "regex": "none", 60 "alertText": "* Date prior to " 61 }, 62 "future": { 63 "regex": "none", 64 "alertText": "* Date past " 65 }, 66 "maxCheckbox": { 67 "regex": "none", 68 "alertText": "* Maximum ", 69 "alertText2": " options allowed" 70 }, 71 "minCheckbox": { 72 "regex": "none", 73 "alertText": "* Please select ", 74 "alertText2": " options" 75 }, 76 "equals": { 77 "regex": "none", 78 "alertText": "* Fields do not match" 79 }, 80 "creditCard": { 81 "regex": "none", 82 "alertText": "* Invalid credit card number" 83 }, 84 "phone": { 85 // credit: jquery.h5validate.js / orefalo 86 "regex": /^[0-9-+/(/)]*$/g, 87 "alertText": "* Invalid phone number" 88 }, 89 "email": { 90 // HTML5 compatible email regex ( http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html# e-mail-state-%28type=email%29 ) 91 "regex": /^(([^<>()[\]\\.,;:\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,}))$/, 92 "alertText": "* Invalid email address" 93 }, 94 "fullname": { 95 "regex": /^([a-zA-Z]+[\'\,\.\-]?[a-zA-Z ]*)+[ ]([a-zA-Z]+[\'\,\.\-]?[a-zA-Z ]+)+$/, 96 "alertText": "* Must be first and last name" 97 }, 98 "zip": { 99 "regex": /^\d{5}
99$|^\d{5}-\d{4}$/, 100 "alertText": "* Invalid zip format" 101 }, 102 "integer": { 103 "regex": /^[\-\+]?\d+$/, 104 "alertText": "* Not a valid integer" 105 }, 106 "number": { 107 // Number, including positive, negative, and floating decimal. credit: orefalo 108 "regex": /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/, 109 "alertText": "* Invalid floating decimal number" 110 }, 111 "date": { 112 // Check if date is valid by leap year 113 "func": function(field) { 114 var pattern = new RegExp(/^(\d{4})[\/\-\.](0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])$/); 115 var match = pattern.exec(field.val()); 116 if (match == null) 117 return false; 118 119 var year = match[1]; 120 var month = match[2] * 1; 121 var day = match[3] * 1; 122 var date = new Date(year, month - 1, day); 123 // because months starts from 0. 124 125 return (date.getFullYear() == year && date.getMonth() == (month - 1) && date.getDate() == day); 126 }, 127 "alertText": "* Invalid date, must be in YYYY-MM-DD format" 128 }, 129 "ipv4": { 130 "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/, 131 "alertText": "* Invalid IP address" 132 }, 133 "ip": { 134 "regex": /((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))/, 135 "alertText": "* Invalid IP address" 136 }, 137 "url": { 138 "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i, 139 "alertText": "* Invalid URL" 140 }, 141 "onlyNumberSp": { 142 "regex": /^[0-9\ ]+$/, 143 "alertText": "* Numbers only" 144 }, 145 "onlyLetterSp": { 146 "regex": /^[a-zA-Z\ \']+$/, 147 "alertText": "* Letters only" 148 },
149 "onlyLetterAccentSp": { 150 "regex": /^[a-z\u00C0-\u017F\ ]+$/i, 151 "alertText": "* Letters only (accents allowed)" 152 }, 153 "onlyLetterNumber": { 154 "regex": /^[0-9a-zA-Z]+$/, 155 "alertText": "* No special characters allowed" 156 }, 157 // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings 158 "ajaxUserCall": { 159 "url": "ajaxValidateFieldUser", 160 // you may want to pass extra data on the ajax call 161 "extraData": "name=eric", 162 "alertText": "* This user is already taken", 163 "alertTextLoad": "* Validating, please wait" 164 }, 165 "ajaxUserCallPhp": { 166 "url": "phpajax/ajaxValidateFieldUser.php", 167 // you may want to pass extra data on the ajax call 168 "extraData": "name=eric", 169 // if you provide an "alertTextOk", it will show as a green prompt when the field validates 170 "alertTextOk": "* This username is available", 171 "alertText": "* This user is already taken", 172 "alertTextLoad": "* Validating, please wait" 173 }, 174 "ajaxNameCall": { 175 // remote json service location 176 "url": "ajaxValidateFieldName", 177 // error 178 "alertText": "* This name is already taken", 179 // if you provide an "alertTextOk", it will show as a green prompt when the field validates 180 "alertTextOk": "* This name is available", 181 // speaks by itself 182 "alertTextLoad": "* Validating, please wait" 183 }, 184 "ajaxNameCallPhp": { 185 // remote json service location 186 "url": "phpajax/ajaxValidateFieldName.php", 187 // error 188 "alertText": "* This name is already taken", 189 // speaks by itself 190 "alertTextLoad": "* Validating, please wait" 191 }, 192 "validate2fields": { 193 "alertText": "* Please input HELLO" 194 }, 195 //tls warning:homegrown not fielded 196 "dateFormat": { 197 "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/, 198 "alertText": "* Invalid Date" 199 }, 200 //tls warning:homegrown not fielded 201 "dateTimeFormat": { 202 "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/, 203 "alertText": "* Invalid Date or Date Format", 204 "alertText2": "Expected Format: ", 205 "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM or ", 206 "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM" 207 } 208 }; 209 210 } 211 }; 212 213 $.validationEngineLanguage.newLang(); 214 215})(jQuery);
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.