Skip to content

Commit 6e32683

Browse files
committed
Added support for datalist and type=date in the html5 module
1 parent 133e6a8 commit 6e32683

File tree

10 files changed

+33
-11
lines changed

10 files changed

+33
-11
lines changed

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

form-validator/html5.dev.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,31 @@
77
* html5 fallback. It makes older browsers support the following
88
* - validation when type="email"
99
* - validation when type="url"
10+
* - validation when type="time"
1011
* - validation when type="number" and max="" min=""
1112
* - validation when pattern="REGEXP"
13+
* - Using datalist element for creating suggestions
1214
* - placeholders
1315
*
1416
* @website http://formvalidator.net/
1517
* @license Dual licensed under the MIT or GPL Version 2 licenses
16-
* @version 2.1.53
18+
* @version 2.1.54
1719
*/
1820
(function($, window) {
1921

2022
"use strict";
2123

22-
var SUPPORTS_PLACEHOLDER = 'placeholder' in document.createElement('input');
24+
var SUPPORTS_PLACEHOLDER = 'placeholder' in document.createElement('input'),
25+
SUPPORTS_DATALIST = 'options' in document.createElement('datalist');
2326

2427
$(window).bind('validatorsLoaded formValidationSetup', function(evt, $form) {
2528

2629
if( !$form ) {
2730
$form = $('form');
2831
}
2932

33+
var hasLoadedDateModule = false;
34+
3035
$form.each(function() {
3136
var $f = $(this),
3237
$formInputs = $f.find('input,textarea,select'),
@@ -39,12 +44,22 @@
3944
attrs = {};
4045

4146
switch ( ($input.attr('type') || '').toLowerCase() ) {
47+
case 'time':
48+
validation.push('time');
49+
if( !$.formUtils.validators.validate_date && !hasLoadedDateModule ) {
50+
hasLoadedDateModule = true;
51+
$.formUtils.loadModules('date');
52+
}
53+
break;
4254
case 'url':
4355
validation.push('url');
4456
break;
4557
case 'email':
4658
validation.push('email');
4759
break;
60+
case 'date':
61+
validation.push('date');
62+
break;
4863
case 'number':
4964
validation.push('number');
5065
var max = $input.attr('max'),
@@ -75,6 +90,13 @@
7590
attrs['data-validation-length'] = 'max'+$input.attr('maxlength');
7691
}
7792

93+
if( !SUPPORTS_DATALIST && $input.attr('list') ) {
94+
var suggestions = [];
95+
$('#'+$input.attr('list')+' option').each(function() {
96+
suggestions.push($(this).attr('value'));
97+
});
98+
$.formUtils.suggest( $input, suggestions );
99+
}
78100

79101
if( validation.length ) {
80102
if( !isRequired ) {

form-validator/html5.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/jquery.form-validator.js

Lines changed: 1 addition & 1 deletion
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.53
8+
* @version 2.1.54
99
*/
1010
(function($) {
1111

form-validator/jquery.form-validator.min.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/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.53
13+
* @version 2.1.54
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.53
15+
* @version 2.1.54
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.53
16+
* @version 2.1.54
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.53
12+
* @version 2.1.54
1313
*/
1414
$.formUtils.addValidator({
1515
name : 'ukvatnumber',

0 commit comments

Comments
 (0)