Skip to content

Commit 9dd1e7e

Browse files
committed
Fix for datepicker and issue victorjonsson#80
1 parent 239ad24 commit 9dd1e7e

File tree

10 files changed

+72
-14
lines changed

10 files changed

+72
-14
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,11 @@ it calls jQ func **$.formUtils.validateInput** to validate the single input when
294294

295295
## Changelog
296296

297-
#### 3.1.36
297+
#### 2.1.40
298+
* Incorrect error-styling when using datepicker or suggestions is now fixed
299+
* Incorrect error-styling of select elements is now fixed
300+
301+
#### 2.1.36
298302
* Now possible to use the native reset() function to clear error messages and error styling of the input elements
299303

300304
#### 2.1.34

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

form-validator/form-test.html

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>Form Test</title>
6-
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0-wip/css/bootstrap.min.css" />
6+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-wip/css/bootstrap.min.css" />
7+
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/black-tie/jquery-ui.css" />
78
<style>
89

910
/* Form and inputs */
@@ -68,6 +69,22 @@
6869
<input name="Swedish county suggestion" data-validation="swecounty" type="text" id="swedish-county-suggestions" class="form-control" />
6970
</div>
7071

72+
<div class="form-group">
73+
<label class="control-label">Year</label>
74+
<input name="birth" class="form-control"
75+
data-validation="date"
76+
data-validation-format="yyyy-mm-dd"
77+
data-suggestions="2014-01-15,2014-01-16,2014-01-17" />
78+
</div>
79+
80+
<div class="form-group">
81+
<label class="control-label">Datepicker</label>
82+
<input name="birth2" class="form-control"
83+
data-validation="date"
84+
data-validation-format="mm/dd/yyyy"
85+
id="datepicker" />
86+
</div>
87+
7188
<div class="form-group password-strength">
7289
<label class="control-label" for="password">Display password strength (only strong)</label>
7390
<input name="password" type="password" id="password" class="form-control" data-validation="strength" data-validation-strength="3" />
@@ -109,7 +126,7 @@
109126
<div class="form-group">
110127
<label class="control-label">Text</label>
111128
(<span id="max-len">20</span> chars left)<br />
112-
<textarea id="text-area" name="some-text"></textarea>
129+
<textarea id="text-area" class="form-control" name="some-text"></textarea>
113130
</div>
114131

115132
<div class="form-group">
@@ -189,19 +206,31 @@
189206
<label class="control-label">Country</label>
190207
<input name="test" data-validation="country" data-validation-error-msg="No valid country given" />
191208
</div>
209+
<div class="form-group">
210+
<label class="control-label">Alphanumeric (will only be validated if the checkbox is checked)</label>
211+
<input name="test2"
212+
data-validation="alphanumeric"
213+
data-validation-error-msg="Invalid..."
214+
data-validation-if-checked="checker" />
215+
<br />
216+
<input type="checkbox" name="checker" />
217+
</div>
192218
<p>
193219
<input type="submit" class="button">
194220
<input type="reset" class="button">
195221
</p>
196222
</form>
197223
</div>
198224
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
225+
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
199226
<script src="jquery.form-validator.js"></script>
200227
<script>
201228
(function($, window) {
202229

203230
var dev = window.location.hash.indexOf('dev') > -1 ? '.dev' : '';
204231

232+
// setup datepicker
233+
$("#datepicker").datepicker();
205234

206235
// Add a new validator
207236
$.formUtils.addValidator({
@@ -273,7 +302,15 @@
273302
console.log('About to validate input "'+this.name+'"');
274303
})
275304
.on('validation', function(evt, isValid) {
276-
console.log('Input '+this.name+' is '+( isValid ? 'VALID':'NOT VALID'));
305+
var validationResult = '';
306+
if( isValid === null ) {
307+
validationResult = 'not validated';
308+
} else if( isValid ) {
309+
validationResult = 'VALID';
310+
} else {
311+
validationResult = 'INVALID';
312+
}
313+
console.log('Input '+this.name+' is '+validationResult);
277314
});
278315

279316
})(jQuery, window);

form-validator/jquery.form-validator.js

Lines changed: 19 additions & 2 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.41
8+
* @version 2.1.42
99
*/
1010
(function($) {
1111

@@ -165,6 +165,23 @@
165165
if(!eventContext)
166166
eventContext = 'blur';
167167

168+
if( (this.valAttr('suggestion-nr') || this.hasClass('hasDatepicker') ) && !window.postponedValidation ) {
169+
// This validation has to be postponed
170+
var _self = this;
171+
window.postponedValidation = function() {
172+
console.log('running the waiting validation');
173+
_self.validateInputOnBlur(language, conf, attachKeyupEvent);
174+
window.postponedValidation = false;
175+
};
176+
setTimeout(function() {
177+
if( window.postponedValidation ) {
178+
window.postponedValidation();
179+
}
180+
}, 200);
181+
182+
return this;
183+
}
184+
168185
language = $.extend({}, $.formUtils.LANG, language || {});
169186
_removeErrorStyle(this, conf);
170187

@@ -179,7 +196,7 @@
179196
eventContext
180197
);
181198

182-
$elem.trigger('validation', [validation===true]);
199+
$elem.trigger('validation', [validation===null ? null : validation===true]);
183200

184201
if(validation === true) {
185202
$elem

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.41
13+
* @version 2.1.42
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.41
15+
* @version 2.1.42
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.41
16+
* @version 2.1.42
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.41
12+
* @version 2.1.42
1313
*/
1414
$.formUtils.addValidator({
1515
name : 'ukvatnumber',

0 commit comments

Comments
 (0)