I have a text box which I have masked like
$.mask.definitions['x'] = "[0-9]";
$(".address").mask("xxx:xxx:xxx:xxx");
Here I always want to add range as well i.e xxx < 256.
What will be the best way to do this
TIA
I have a text box which I have masked like
$.mask.definitions['x'] = "[0-9]";
$(".address").mask("xxx:xxx:xxx:xxx");
Here I always want to add range as well i.e xxx < 256.
What will be the best way to do this
TIA
On
demo: https://jsbin.com/pohehil
var masking = function(value) {
if (value.match(/25[0-9]{0,1}/)) {
return "255"
} else if (value.match(/2[0-9]{0,2}/)) {
return "250"
} else {
return "200"
}
}
var options = {
onKeyPress: function(cep, e, field, options) {
var mask = ["200", "200", "200", "200"];
var values = cep.split(":");
for (var i = 0; i < values.length; i++) {
mask[i] = masking(values[i]);
}
$(e.target).mask(mask.join(":"), options);
},
translation: {
2: { pattern: /[0-2]/ },
5: { pattern: /[0-5]/ }
}
};
$(".address").mask("200:200:200:200", options);