|
5 | 5 | * Documentation and issue tracking on Github <https://github.com/victorjonsson/jQuery-Form-Validator/> |
6 | 6 | * |
7 | 7 | * @license Dual licensed under the MIT or GPL Version 2 licenses |
8 | | -* @version 1.9.29 |
| 8 | +* @version 1.9.30 |
9 | 9 | */ |
10 | 10 | (function($) { |
11 | 11 |
|
|
1011 | 1011 | badLength : 'You have to give an answer between ', |
1012 | 1012 | notConfirmed : 'Values could not be confirmed', |
1013 | 1013 | badDomain : 'Incorrect domain value', |
1014 | | - badUrl : 'Incorrect url value', |
1015 | | - badFloat : 'Incorrect float value', |
| 1014 | + badUrl : 'The answer you gave was not a correct URL', |
1016 | 1015 | badCustomVal : 'You gave an incorrect answer', |
1017 | | - badInt : 'Incorrect integer value', |
| 1016 | + badInt : 'The answer you gave was not a correct number', |
1018 | 1017 | badSecurityNumber : 'Your social security number was incorrect', |
1019 | 1018 | badUKVatAnswer : 'Incorrect UK VAT Number', |
1020 | 1019 | badStrength : 'The password isn\'t strong enough', |
1021 | 1020 | badNumberOfSelectedOptionsStart : 'You have to choose at least ', |
1022 | | - badNumberOfSelectedOptionsEnd : ' answers' |
| 1021 | + badNumberOfSelectedOptionsEnd : ' answers', |
| 1022 | + badAlphaNumeric : 'The answer you gave must contain only alphanumeric characters ', |
| 1023 | + badAlphaNumericExtra: ' and ' |
1023 | 1024 | } |
1024 | 1025 | }; |
1025 | 1026 |
|
|
1250 | 1251 | errorMessageKey: 'badInt' |
1251 | 1252 | }); |
1252 | 1253 |
|
| 1254 | + /* |
| 1255 | + * Validate alpha numeric |
| 1256 | + */ |
| 1257 | + $.formUtils.addValidator({ |
| 1258 | + name : 'validate_alphanumeric', |
| 1259 | + validate : function(val, $el, config, language) { |
| 1260 | + var patternStart = '^([a-zA-Z0-9', |
| 1261 | + patternEnd = ']+)$', |
| 1262 | + additionalChars = $el.attr('data-validation-allowing'), |
| 1263 | + pattern = ''; |
| 1264 | + |
| 1265 | + if( additionalChars ) { |
| 1266 | + pattern = patternStart + additionalChars + patternEnd; |
| 1267 | + var extra = additionalChars.replace(/\\/g, ''); |
| 1268 | + if( extra.indexOf(' ') > -1 ) { |
| 1269 | + extra = extra.replace(' ', ''); |
| 1270 | + extra += ' and spaces '; |
| 1271 | + } |
| 1272 | + this.errorMessage = language.badAlphaNumeric + language.badAlphaNumericExtra + extra; |
| 1273 | + } else { |
| 1274 | + pattern = patternStart + patternEnd; |
| 1275 | + this.errorMessage = language.badAlphaNumeric; |
| 1276 | + } |
| 1277 | + |
| 1278 | + return new RegExp(pattern).test(val); |
| 1279 | + }, |
| 1280 | + errorMessage : '', |
| 1281 | + errorMessageKey: '' |
| 1282 | + }); |
| 1283 | + |
1253 | 1284 | /* |
1254 | 1285 | * Validate against regexp |
1255 | 1286 | */ |
|
0 commit comments