mirror of
https://github.com/wassname/wtforms-parsleyjs.git
synced 2026-06-27 18:27:26 +08:00
Improved data-parsley-datefield validator, fixed previous issue of '%Y-%m-%d' being matched by '1996-2-'.
This commit is contained in:
@@ -10,14 +10,14 @@ $(document).ready(function() {
|
||||
'A': '[a-z]+',
|
||||
'B': '[a-z]+',
|
||||
'Y': '[0-9]{4}',
|
||||
'm': '[0-9]{0,2}',
|
||||
'd': '[0-9]{0,2}',
|
||||
'H': '[0-9]{0,2}',
|
||||
'M': '[0-9]{0,2}',
|
||||
'S': '[0-9]{0,2}',
|
||||
'm': '[0-9]{1,2}',
|
||||
'd': '[0-9]{1,2}',
|
||||
'H': '[0-9]{1,2}',
|
||||
'M': '[0-9]{1,2}',
|
||||
'S': '[0-9]{1,2}',
|
||||
's': '[0-9]+',
|
||||
'Z': 'UTC|Z|[+-][0-9][0-9]:?[0-9][0-9]',
|
||||
'I': '[0-9]{0,2}',
|
||||
'I': '[0-9]{1,2}',
|
||||
'p': 'AM|PM'
|
||||
};
|
||||
// Create a regular expression from the format string, that matches a string of that format.
|
||||
@@ -27,6 +27,7 @@ $(document).ready(function() {
|
||||
if (!d) throw Error("Unknown format descripter: " + fd);
|
||||
return '(' + d + ')';
|
||||
}), 'i');
|
||||
console.log(re)
|
||||
return re.test(str);
|
||||
}, 32).addMessage('en', 'datefield', 'The input needs to be in the correct date format.')
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user