Skip to content

Commit 857d0bf

Browse files
committed
1 parent d6e7a01 commit 857d0bf

17 files changed

+54
-38
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ it calls jQ func **$.formUtils.validateInput** to validate the single input when
294294

295295
## Changelog
296296

297+
298+
### 2.1.15
299+
* E-mail addresses can now contain + symbol
300+
* Correction of the US states in validation "federatestate"
301+
* Fixed bug in server validation
302+
297303
### 2.1.9
298304
* File validation now support multiple files
299305
* Length validation can now be used to validate the number of uploaded files using a file input that supports multiple files

form-validator/date.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#location-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.9
13+
* @version 2.1.15
1414
*/
1515
(function($) {
1616

form-validator/date.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/file.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.9
13+
* @version 2.1.15
1414
*/
1515
(function($, window) {
1616

form-validator/file.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/form-test.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<label class="control-label">Server validation</label>
8989
<input class="form-control" name="code"
9090
data-validation-help="The word is &quot;secret&quot;"
91-
data-validation="server"
91+
data-validation="alphanumeric server"
9292
data-validation-url="http://formvalidator.net/validate-email.php" />
9393
</div>
9494

@@ -190,6 +190,7 @@
190190
$.formUtils.addValidator({
191191
name : 'even_number',
192192
validatorFunction : function(value, $el, config, language, $form) {
193+
console.log('Event number');
193194
return parseInt(value, 10) % 2 === 0;
194195
},
195196
borderColorOnError : '',

form-validator/jquery.form-validator.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @website http://formvalidator.net/
77
* @license Dual licensed under the MIT or GPL Version 2 licenses
8-
* @version 2.1.9
8+
* @version 2.1.15
99
*/
1010
(function($) {
1111

@@ -79,12 +79,14 @@
7979
* @param {Object} [language] Optional, will override $.formUtils.LANG
8080
* @param {Object} [config] Optional, will override the default settings
8181
* @param {Boolean} [attachKeyupEvent] Optional
82+
* @param {String} [eventContext]
8283
* @return {jQuery}
8384
*/
84-
$.fn.validateInputOnBlur = function(language, config, attachKeyupEvent) {
85-
if(attachKeyupEvent === undefined) {
85+
$.fn.validateInputOnBlur = function(language, config, attachKeyupEvent, eventContext) {
86+
if(attachKeyupEvent === undefined)
8687
attachKeyupEvent = true;
87-
}
88+
if(!eventContext)
89+
eventContext = 'blur';
8890

8991
language = $.extend($.formUtils.LANG, language || {});
9092
config = $.extend($.formUtils.defaultConfig(), config || {});
@@ -99,11 +101,6 @@
99101

100102
validationRule = $element.attr(config.validationRuleAttribute);
101103

102-
if( !attachKeyupEvent && validationRule == 'server' ) {
103-
// do not validate server side on keyup event
104-
return this;
105-
}
106-
107104
// Remove possible error style applied by previous validation
108105
$element
109106
.removeClass(config.errorElementClass)
@@ -113,13 +110,14 @@
113110

114111
// Twitter bs
115112
$form.find('.has-error').removeClass('has-error');
113+
$element.removeClass('valid').parent().removeClass('has-success');
116114

117115
// if element has custom err msg container, clear it
118116
if( elementErrMsgObj != null) {
119117
elementErrMsgObj.innerHTML = '';
120118
}
121119

122-
var validation = $.formUtils.validateInput($element, language, config, $form);
120+
var validation = $.formUtils.validateInput($element, language, config, $form, eventContext);
123121

124122
if(validation === true) {
125123
$element
@@ -155,7 +153,7 @@
155153

156154
if(attachKeyupEvent) {
157155
$element.bind('keyup', function() {
158-
$(this).validateInputOnBlur(language, config, false);
156+
$(this).validateInputOnBlur(language, config, false, 'keyup');
159157
});
160158
}
161159
}
@@ -253,7 +251,8 @@
253251
$element,
254252
language,
255253
config,
256-
$form
254+
$form,
255+
'submit'
257256
);
258257

259258
if(validation !== true) {
@@ -533,6 +532,8 @@
533532
addValidator : function(validator) {
534533
// prefix with "validate_" for backward compatibility reasons
535534
var name = validator.name.indexOf('validate_') === 0 ? validator.name : 'validate_'+validator.name;
535+
if( validator.validateOnKeyUp === undefined )
536+
validator.validateOnKeyUp = true;
536537
this.validators[name] = validator;
537538
},
538539

@@ -672,9 +673,10 @@
672673
* @param {Object} language ($.formUtils.LANG)
673674
* @param {Object} config
674675
* @param {jQuery} $form
676+
* @param {String} [eventContext]
675677
* @return {String|Boolean}
676678
*/
677-
validateInput : function($element, language, config, $form) {
679+
validateInput : function($element, language, config, $form, eventContext) {
678680

679681
var value = $.trim( $element.val() || ''),
680682
optional = $element.valAttr('optional'),
@@ -734,7 +736,10 @@
734736
$element = $("[name='"+$element.attr('name')+"']:eq(0)");
735737
}
736738

737-
var isValid = validator.validatorFunction(value, $element, config, language, $form);
739+
var isValid = true;
740+
if( eventContext != 'keyup' || validator.validateOnKeyUp ) {
741+
isValid = validator.validatorFunction(value, $element, config, language, $form);
742+
}
738743

739744
if(!isValid) {
740745
validationErrorMsg = $element.attr(config.validationErrorMsgAttribute);
@@ -745,6 +750,7 @@
745750
}
746751
return false; // breaks the iteration
747752
}
753+
748754
} else {
749755
console.warn('Using undefined validator "'+rule+'"');
750756
}
@@ -1142,13 +1148,13 @@
11421148
$.formUtils.addValidator({
11431149
name : 'email',
11441150
validatorFunction : function(email) {
1145-
var emailFilter = /^([a-zA-Z0-9_\.\-])+@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
1146-
if(emailFilter.test(email)) {
1147-
var parts = email.split('@');
1148-
if(parts.length == 2) {
1149-
return $.formUtils.validators.validate_domain.validatorFunction(parts[1]);
1150-
}
1151+
1152+
var emailParts = email.split('@');
1153+
if( emailParts.length == 2 ) {
1154+
return $.formUtils.validators.validate_domain.validatorFunction(emailParts[1]) &&
1155+
!(/[^a-zA-Z0-9_\+\.\-]/.test(emailParts[0]));
11511156
}
1157+
11521158
return false;
11531159
},
11541160
errorMessage : '',

form-validator/jquery.form-validator.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

form-validator/location.dev.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#location-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.9
13+
* @version 2.1.15
1414
*/
1515
(function($) {
1616

@@ -35,7 +35,7 @@
3535
validatorFunction : function(str) {
3636
return $.inArray(str.toLowerCase(), this.states) > -1;
3737
},
38-
states : ['alabama','alaska','arkansas','california','colorado','connecticut','delaware','florida','georgia','hawaii','idaho','illinois','indiana','iowa','kansas','kentucky','louisiana','maine','marylan ','massachusetts','michigan','minnesota','mississippi','missouri','montana','nebraska','nevada','new hampshire','new jersey','new mexico','new york','north carolina','north dakota','ohio','oklahoma','oregon','pennsylvania','rhode island','south carolina','south dakota','tennessee','texas','utah','vermont','virginia','washington','west virginia','wisconsin','wyoming'],
38+
states : ['alabama','alaska', 'arizona', 'arkansas','california','colorado','connecticut','delaware','florida','georgia','hawaii','idaho','illinois','indiana','iowa','kansas','kentucky','louisiana','maine','maryland', 'district of columbia', 'massachusetts','michigan','minnesota','mississippi','missouri','montana','nebraska','nevada','new hampshire','new jersey','new mexico','new york','north carolina','north dakota','ohio','oklahoma','oregon','pennsylvania','rhode island','south carolina','south dakota','tennessee','texas','utah','vermont','virginia','washington','west virginia','wisconsin','wyoming'],
3939
errorMessage : '',
4040
errorMessageKey: 'badCustomVal'
4141
});

0 commit comments

Comments
 (0)