Skip to content

Commit b946cd6

Browse files
committed
now possible to allow non-zero-leading dates, issue victorjonsson#205
1 parent e1f8d9b commit b946cd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+68
-57
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ module.exports = function(grunt) {
130130
grunt.loadNpmTasks("grunt-contrib-watch");
131131
grunt.loadNpmTasks('grunt-contrib-qunit');
132132

133-
grunt.registerTask("build", ["qunit", "version", "concat", "uglify"]);
134-
grunt.registerTask("default", ["jshint", "build"]);
133+
grunt.registerTask("build", ["version", "concat", "uglify"]);
134+
grunt.registerTask("default", ["jshint", "qunit", "build"]);
135135

136136
};

form-validator/brazil.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* @website http://formvalidator.net/#brazil-validators
1313
* @license MIT
14-
* @version 2.2.92
14+
* @version 2.2.93
1515
*/
1616

1717
$.formUtils.addValidator({

form-validator/brazil.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/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 MIT
13-
* @version 2.2.92
13+
* @version 2.2.93
1414
*/
1515
(function($) {
1616

form-validator/date.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
*
44
* @website by
55
* @license MIT
6-
* @version 2.2.92
6+
* @version 2.2.93
77
*/
88
!function(a){a.formUtils.addValidator({name:"time",validatorFunction:function(a){if(null===a.match(/^(\d{2}):(\d{2})$/))return!1;var b=parseInt(a.split(":")[0],10),c=parseInt(a.split(":")[1],10);return b>23||c>59?!1:!0},errorMessage:"",errorMessageKey:"badTime"}),a.formUtils.addValidator({name:"birthdate",validatorFunction:function(b,c,d){var e="yyyy-mm-dd";c.valAttr("format")?e=c.valAttr("format"):"undefined"!=typeof d.dateFormat&&(e=d.dateFormat);var f=a.formUtils.parseDate(b,e);if(!f)return!1;var g=new Date,h=g.getFullYear(),i=f[0],j=f[1],k=f[2];if(i===h){var l=g.getMonth()+1;if(j===l){var m=g.getDate();return m>=k}return l>j}return h>i&&i>h-124},errorMessage:"",errorMessageKey:"badDate"})}(jQuery);

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/#file-validators
1212
* @license MIT
13-
* @version 2.2.92
13+
* @version 2.2.93
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/html5.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* @website http://formvalidator.net/
1919
* @license MIT
20-
* @version 2.2.92
20+
* @version 2.2.93
2121
*/
2222
(function($, window) {
2323

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: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @website http://formvalidator.net/
77
* @license MIT
8-
* @version 2.2.92
8+
* @version 2.2.93
99
*/
1010
(function ($) {
1111

@@ -1021,12 +1021,9 @@
10211021
// Filter out specified characters
10221022
var ignore = $elem.valAttr('ignore');
10231023
if( ignore ) {
1024-
console.log('HAS IGNORE '+ value);
10251024
$.each(ignore.split(''), function(i, char) {
1026-
console.log(char+' -> IGNORED');
10271025
value = value.replace(new RegExp('\\'+char, 'g'), '');
10281026
});
1029-
console.log('AFTER IGNORE FILTER '+ value);
10301027
}
10311028

10321029
$.split(validationRules, function (rule) {
@@ -1103,9 +1100,10 @@
11031100
*
11041101
* @param {String} val
11051102
* @param {String} dateFormat
1103+
* @param {Boolean} [addMissingLeadingZeros]
11061104
* @return {Array}|{Boolean}
11071105
*/
1108-
parseDate: function (val, dateFormat) {
1106+
parseDate: function (val, dateFormat, addMissingLeadingZeros) {
11091107
var divider = dateFormat.replace(/[a-zA-Z]/gi, '').substring(0, 1),
11101108
regexp = '^',
11111109
formatParts = dateFormat.split(divider || null),
@@ -1117,6 +1115,17 @@
11171115

11181116
regexp += '$';
11191117

1118+
if (addMissingLeadingZeros) {
1119+
var newValueParts = [];
1120+
$.each(val.split(divider), function(i, part) {
1121+
if(part.length === 1) {
1122+
part = '0'+part;
1123+
}
1124+
newValueParts.push(part);
1125+
});
1126+
val = newValueParts.join(divider);
1127+
}
1128+
11201129
matches = val.match(new RegExp(regexp));
11211130
if (matches === null) {
11221131
return false;
@@ -1151,7 +1160,7 @@
11511160
* skum fix. är talet 05 eller lägre ger parseInt rätt int annars får man 0 när man kör parseInt?
11521161
*
11531162
* @param {String} val
1154-
* @param {Number}
1163+
* @return {Number}
11551164
*/
11561165
parseDateInt: function (val) {
11571166
if (val.indexOf('0') === 0) {
@@ -1784,8 +1793,9 @@
17841793
$.formUtils.addValidator({
17851794
name: 'date',
17861795
validatorFunction: function (date, $el, conf) {
1787-
var dateFormat = $el.valAttr('format') || conf.dateFormat || 'yyyy-mm-dd';
1788-
return $.formUtils.parseDate(date, dateFormat) !== false;
1796+
var dateFormat = $el.valAttr('format') || conf.dateFormat || 'yyyy-mm-dd',
1797+
addMissingLeadingZeros = $el.valAttr('require-leading-zero') === 'false';
1798+
return $.formUtils.parseDate(date, dateFormat, addMissingLeadingZeros) !== false;
17891799
},
17901800
errorMessage: '',
17911801
errorMessageKey: 'badDate'

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/jsconf.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @website http://formvalidator.net/#location-validators
99
* @license MIT
10-
* @version 2.2.92
10+
* @version 2.2.93
1111
*/
1212
(function($) {
1313

form-validator/jsconf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
*
44
* @website by
55
* @license MIT
6-
* @version 2.2.92
6+
* @version 2.2.93
77
*/
88
!function(a){"use strict";a.setupValidation=function(b){var c=a(b.form||"form");a.each(b.validate||b.validation||{},function(b,d){var e;e="#"===b[0]?a(b):c.find("."===b[0]?b:'*[name="'+b+'"]'),e.attr("data-validation",d.validation),a.each(d,function(a,b){"validation"!==a&&b!==!1&&(b===!0&&(b="true"),"_"===a[0]?(a=a.substring(1),b===!1?e.removeAttr(a):e.attr(a,b)):e.valAttr(a,b))})}),a.validate(b)}}(jQuery);

form-validator/lang/cz.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @website http://formvalidator.net/
88
* @license MIT
9-
* @version 2.2.92
9+
* @version 2.2.93
1010
*/
1111
(function($, window) {
1212

form-validator/lang/cz.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/lang/de.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @website http://formvalidator.net/
88
* @license MIT
9-
* @version 2.2.92
9+
* @version 2.2.93
1010
*/
1111
(function($, window) {
1212

form-validator/lang/de.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/lang/es.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* @website http://formvalidator.net/
88
* @license Dual licensed under the MIT or GPL Version 2 licenses
9-
* @version 2.2.92
9+
* @version 2.2.93
1010
*/
1111
(function($, window) {
1212

0 commit comments

Comments
 (0)