So i'm trying to use jQuery-Mask-Plugin but the documentation its not very clear to me regarding validation. Meaning i'm trying to use the basic setup for a date input.
<input id="mydateinput" name="mydateinput" type="text"/>
$('.mydateinput').mask('00-00-0000');
This works fine but with this i can put a a date like so 99-99-9999 and i would like to restrict the date input like so 31-12-1700.
I do have this regex to validate the input:
var test = /(0[1-9]|[12]\d|3[01])-(0[1-9]|1[0-2])-([12]\d{3})/;//dd-mm-yyyy
I would like to combine this regex with the plugin. But this doesn´t work, anyone with ideas ?
$('.mydateinput').mask('ZX-YK-0000',{
translation: {
'ZX': { pattern: /(0[1-9]|[12]\d|3[01])/, optional: true },
'YK': { pattern: /(0[1-9]|1[0-2])/, optional:true }
}
});
Aucun commentaire:
Enregistrer un commentaire