I'm using jQuery-Mask-Plugin to mask a time input.
I've configured it like so:
$('#time').mask('99r00', {translation: { 'r': { pattern: /[\.,:]/ }}});
With this mask the user can input the following legal times:
21:00
21.00
21,00
,30
This almost works like I want it but there is one thing that I want to achieve for the user:
If the user inputs 2100
I want to mask it to 21:00
. So it needs to know the default character is :
.
The mask doesn't know which character in the pattern he needs to put in there and disabled further typing.
So how to set a default character for the translation option?
Thanks.
I have modified the plugin by adding a custom option to translation called defaults
. Demo.
//getMasked: function
//... lines 298 - 302
else if (translation.defaults) {
buf[addMethod](translation.defaults);
m += offset;
v -= offset;
}
//...
$('#timetrans').mask('99r00', {translation: {
'r': { pattern: /[:,\\.]/, defaults: ':'}}});