Open cbranca opened 6 years ago
@cbranca ,
As example for an Ip you would like to use 10.200.0.* ?
I guess updating the regex to (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|*
@cbranca ,
Maybe this one
"ip": { //ip-address mask
mask: "(i[i[i]])|\\*.(i[i[i]])|\\*.(i[i[i]])|\\*.(i[i[i]])|\\*",
definitions: {
"i": {
validator: function (chrs, maskset, pos, strict, opts) {
if (pos - 1 > -1 && maskset.buffer[pos - 1] !== ".") {
chrs = maskset.buffer[pos - 1] + chrs;
if (pos - 2 > -1 && maskset.buffer[pos - 2] !== ".") {
chrs = maskset.buffer[pos - 2] + chrs;
} else chrs = "0" + chrs;
} else chrs = "00" + chrs;
return new RegExp("25[0-5]|2[0-4][0-9]|[01][0-9][0-9]").test(chrs);
}
}
},
onUnMask: function (maskedValue, unmaskedValue, opts) {
return maskedValue;
},
inputmode: "numeric",
},
Hi @RobinHerbots , sorry for late response. I solved this way:
Inputmask.extendAliases({
ipstar: {
mask: '(i[i[i]]|*).(i[i[i]]|*).(i[i[i]]|*).(i[i[i]]|*)',
definitions: {
'i': {
validator: function (chrs, maskset, pos, strict, opts) {
if (pos - 1 > -1 && maskset.buffer[pos - 1] !== '.') {
chrs = maskset.buffer[pos - 1] + chrs;
if (pos - 2 > -1 && maskset.buffer[pos - 2] !== '.') {
chrs = maskset.buffer[pos - 2] + chrs;
} else {
chrs = '0' + chrs;
}
} else {
chrs = '00' + chrs;
}
return new RegExp('25[0-5]|2[0-4][0-9]|[01][0-9][0-9]').test(chrs);
}
},
'*': {
validator: '[\\*]',
cardinality: 1
}
},
onUnMask: function (maskedValue, unmaskedValue, opts) {
return maskedValue;
},
inputmode: 'verbatim'
}
});
var im = new Inputmask('ipstar');
Hi, I'm having some trouble creating a custom mask. I need the "ip" mask that allows to insert also "". I used the "ip" mask and added the following regex: '25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|\' But it doesn't work, can you give me some help? This is the code: