Skip to content

Commit 57f7671

Browse files
committed
Fixed border color reset bug, and modules can now be loaded from remote websites
1 parent 08dac15 commit 57f7671

11 files changed

+29
-55
lines changed

README.md

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

295295
## Changelog
296296

297+
#### 2.1.6
298+
* Modules can now be loaded from remote website
299+
297300
#### 2.1.5
298301
* Fixed language bug (issue #43 on github)
299302
* Validation on server side is now triggered by the blur event

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.5
13+
* @version 2.1.6
1414
*/
1515
(function($) {
1616

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.5
13+
* @version 2.1.6
1414
*/
1515
(function($, window) {
1616

form-validator/form-test.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
</div>
137137
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
138138
<script src="jquery.form-validator.js"></script>
139-
<script src="//code.jquery.com/qunit/qunit-1.12.0.js"></script>
140139
<script>
141140
(function($) {
142141

form-validator/jquery.form-validator.js

Lines changed: 17 additions & 45 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.5
8+
* @version 2.1.6
99
*/
1010
(function($) {
1111

@@ -90,9 +90,6 @@
9090
config = $.extend($.formUtils.defaultConfig(), config || {});
9191
config.errorMessagePosition = 'element';
9292

93-
// Capture default error message
94-
//$.formUtils.figureOutDefaultBorderColor(this);
95-
9693
var $element = this,
9794

9895
// test if there is custom obj to hold element error msg (id = element name + err_msg)
@@ -110,6 +107,7 @@
110107
// Remove possible error style applied by previous validation
111108
$element
112109
.removeClass(config.errorElementClass)
110+
.css('border-color', '')
113111
.parent()
114112
.find('.'+config.errorMessageClass).remove();
115113

@@ -121,10 +119,6 @@
121119
elementErrMsgObj.innerHTML = '';
122120
}
123121

124-
//if(config.borderColorOnError !== '') {
125-
// $element.css('border-color', $.formUtils.defaultBorderColor);
126-
//}
127-
128122
var validation = $.formUtils.validateInput($element, language, config, $form);
129123

130124
if(validation === true) {
@@ -246,9 +240,6 @@
246240
var elementType = $element.attr('type');
247241
if (!ignoreInput($element.attr('name'), elementType)) {
248242

249-
// memorize border color
250-
// $.formUtils.figureOutDefaultBorderColor($element);
251-
252243
var validation = $.formUtils.validateInput(
253244
$element,
254245
language,
@@ -272,14 +263,10 @@
272263
//
273264
// Reset style and remove error class
274265
//
275-
//var borderStyleProp = $.formUtils.defaultBorderColor===null ||
276-
// ($.formUtils.defaultBorderColor.indexOf(' ') > -1 && $.formUtils.defaultBorderColor.indexOf('rgb') == -1)
277-
// ? 'border':'border-color';
278-
266+
$form.find('.has-error').removeClass('has-error');
279267
$form.find('input,textarea,select')
280-
//.css(borderStyleProp, $.formUtils.defaultBorderColor)
268+
.css('border-color', '')
281269
.removeClass(config.errorElementClass);
282-
$form.find('.has-error').removeClass('has-error');
283270

284271
//
285272
// Remove possible error messages from last validation
@@ -494,22 +481,6 @@
494481
}
495482
},
496483

497-
/**
498-
* @param {jQuery} $element
499-
*/
500-
figureOutDefaultBorderColor : function($element) {
501-
var elementType = $element.attr('type');
502-
if (this.defaultBorderColor === null && elementType !== 'submit' && elementType !== 'checkbox' && elementType !== 'radio') {
503-
this.defaultBorderColor = $element.css('border-color');
504-
}
505-
},
506-
507-
/**
508-
* Default border color, will be picked up first
509-
* time form is validated
510-
*/
511-
defaultBorderColor : null,
512-
513484
/**
514485
* Available validators
515486
*/
@@ -615,26 +586,27 @@
615586
$.formUtils.isLoadingModules = true;
616587
}
617588

589+
var cacheSuffix = '?__='+( new Date().getTime() ),
590+
appendToElement = document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0];
591+
618592
$.each(moduleList, function(i, modName) {
619593
modName = $.trim(modName);
620594
if( modName.length == 0 ) {
621595
moduleLoadedCallback();
622596
}
623597
else {
624-
var scriptUrl = path + modName + (modName.substr(-3) == '.js' ? '':'.js');
625-
$.ajax({
626-
url : scriptUrl,
627-
cache : scriptUrl.substr(-7) != '.dev.js',
628-
dataType : 'script',
629-
async : false,
630-
success : function() {
598+
var scriptUrl = path + modName + (modName.substr(-3) == '.js' ? '':'.js'),
599+
script = document.createElement('SCRIPT');
600+
script.type = 'text/javascript';
601+
script.onload = moduleLoadedCallback;
602+
script.src = scriptUrl + ( scriptUrl.substr(-7) == '.dev.js' ? cacheSuffix:'' );
603+
script.onreadystatechange = function() {
604+
// IE 7 fix
605+
if( this.readyState == 'complete' ) {
631606
moduleLoadedCallback();
632-
},
633-
error : function() {
634-
moduleLoadedCallback();
635-
throw new Error('Unable to load form validation module '+modName);
636607
}
637-
});
608+
};
609+
appendToElement.appendChild( script );
638610
}
639611
});
640612
};

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: 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.5
13+
* @version 2.1.6
1414
*/
1515
(function($) {
1616

form-validator/security.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*
1313
* @website http://formvalidator.net/#security-validators
1414
* @license Dual licensed under the MIT or GPL Version 2 licenses
15-
* @version 2.1.5
15+
* @version 2.1.6
1616
*/
1717
(function($) {
1818

form-validator/sweden.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* @website http://formvalidator.net/#swedish-validators
1515
* @license Dual licensed under the MIT or GPL Version 2 licenses
16-
* @version 2.1.5
16+
* @version 2.1.6
1717
*/
1818
(function($, window) {
1919

form-validator/uk.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @website http://formvalidator.net/#uk-validators
1111
* @license Dual licensed under the MIT or GPL Version 2 licenses
12-
* @version 2.1.5
12+
* @version 2.1.6
1313
*/
1414
$.formUtils.addValidator({
1515
name : 'ukvatnumber',

formvalidator.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"validation",
88
"validator"
99
],
10-
"version" : "2.1.5",
10+
"version" : "2.1.6",
1111
"author" : {
1212
"name": "Victor Jonsson",
1313
"url": "http://victorjonsson.se",

0 commit comments

Comments
 (0)