您不应该使用alias
and ,mask
因为您没有声明 aalias
而只是调用inputmask()
with options
。
这是带有注释解释的解决方案。
$('.time').inputmask({
mask:'(h:s:s)|(X)', // X will define our new validator , | mean OR
definitions: {
"X": {
// Needed since you need the word(NONE) comparaison
validator: function(chrs) {return chrs.toUpperCase().localeCompare('NONE')==0 },
cardinality: 4, // Mean 1 instance of our new validator(X) has a value of 4 chars
prevalidator: [
{validator: function(chrs){return chrs.toUpperCase().localeCompare('N')==0 },cardinality:1},
{validator: function(chrs){return chrs.toUpperCase().localeCompare('NO')==0 },cardinality:2},
{validator: function(chrs){return chrs.toUpperCase().localeCompare('NON')==0 },cardinality:3}
],
casing: "upper" // All chars will be casted as UPPER but not during our custom validation
}
}
})
里面有死亡金属:)
$('.time').inputmask({
mask:'(h:s:s)|(X)', // X will define our new validator , | mean OR
regex: Inputmask().opts.aliases.datetime.regex, //Needed for the imported validator
placeholder: "00:00:00", //To get 00:00:00 in place __:__:__
hourFormat: "24", // or 12
definitions: {
"h": Inputmask().opts.aliases.datetime.definitions.h, // first char > 2 will become 09:
"s": Inputmask().opts.aliases.datetime.definitions.s, //first char for minute/second if > 5 become 09
"X": {
// Needed since you need the word(NONE) comparaison
validator: function(chrs) {return chrs.toUpperCase().localeCompare('NONE')==0 },
cardinality: 4, // Mean 1 instance of our new validator(X) has a value of 4 chars
prevalidator: [
{validator: function(chrs){return chrs.toUpperCase().localeCompare('N')==0 },cardinality:1},
{validator: function(chrs){return chrs.toUpperCase().localeCompare('NO')==0 },cardinality:2},
{validator: function(chrs){return chrs.toUpperCase().localeCompare('NON')==0 },cardinality:3}
],
casing: "upper" // All chars will be casted as UPPER but not during our custom validation
}
}
})