inputmask
Advanced tools
Comparing version 5.0.9-beta.33 to 5.0.9-beta.35
@@ -9,5 +9,9 @@ # Change Log | ||
### Updates | ||
- Update IP extension to support greedy option. #2748 | ||
- Properly handle insertMode false in alternation logic. | ||
- Enhance resolving of the ndxInitializer to determine the alternating tests. | ||
### Fixed | ||
- [Question] How to custom placeholder in "ip" alias? #2749 | ||
- Timezone mask #2730 | ||
- Unicode categories such as \p{P} or \p{S} does not work in regexp property #2741 | ||
@@ -14,0 +18,0 @@ - When user press Ctrl+Alt / Alt+Ctrl key in the field, Can input characters with restricted formatting #2736 |
@@ -12,14 +12,9 @@ /* | ||
Inputmask.extendDefinitions({ | ||
"A": { | ||
validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]", | ||
casing: "upper" //auto uppercasing | ||
}, | ||
"&": { //alfanumeric uppercasing | ||
validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]", | ||
casing: "upper" | ||
}, | ||
"#": { //hexadecimal | ||
validator: "[0-9A-Fa-f]", | ||
casing: "upper" | ||
} | ||
"A": { | ||
validator: "[A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]", casing: "upper" //auto uppercasing | ||
}, "&": { //alfanumeric uppercasing | ||
validator: "[0-9A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]", casing: "upper" | ||
}, "#": { //hexadecimal | ||
validator: "[0-9A-Fa-f]", casing: "upper" | ||
} | ||
}); | ||
@@ -30,9 +25,16 @@ | ||
function ipValidator(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 ipValidatorRegex.test(chrs); | ||
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; | ||
if (opts.greedy && parseInt(chrs) > 255 && ipValidatorRegex.test("00" + chrs.charAt(2))) { | ||
return { | ||
refreshFromBuffer: true, | ||
buffer: [...maskset.buffer.slice(0, pos), ".", chrs.charAt(2)], | ||
caret: pos + 2 | ||
}; | ||
} | ||
return ipValidatorRegex.test(chrs); | ||
} | ||
@@ -42,94 +44,72 @@ | ||
Inputmask.extendAliases({ | ||
"cssunit": { | ||
regex: "[+-]?[0-9]+\\.?([0-9]+)?(px|em|rem|ex|%|in|cm|mm|pt|pc)" | ||
}, | ||
"url": { //needs update => https://en.wikipedia.org/wiki/URL | ||
regex: "(https?|ftp)://.*", | ||
autoUnmask: false, | ||
keepStatic: false, | ||
tabThrough: true | ||
}, | ||
"ip": { //ip-address mask | ||
mask: "i{1,3}.j{1,3}.k{1,3}.l{1,3}", | ||
definitions: { | ||
"i": { | ||
validator: ipValidator | ||
}, | ||
"j": { | ||
validator: ipValidator | ||
}, | ||
"k": { | ||
validator: ipValidator | ||
}, | ||
"l": { | ||
validator: ipValidator | ||
} | ||
}, | ||
onUnMask: function (maskedValue, unmaskedValue, opts) { | ||
return maskedValue; | ||
}, | ||
inputmode: "decimal", | ||
substitutes: {",": "."} | ||
}, | ||
"email": { | ||
//https://en.wikipedia.org/wiki/Domain_name#Domain_name_space | ||
//https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names | ||
//should be extended with the toplevel domains at the end | ||
mask: function ({separator, quantifier}) { | ||
var emailMask = "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]"; | ||
var mask = emailMask; | ||
if (separator) { | ||
for (let i = 0; i < quantifier; i++) { | ||
mask += `[${separator}${emailMask}]`; | ||
} | ||
} | ||
return mask; | ||
}, | ||
greedy: false, | ||
casing: "lower", | ||
separator: null, | ||
quantifier: 5, | ||
skipOptionalPartCharacter: "", | ||
onBeforePaste: function (pastedValue, opts) { | ||
pastedValue = pastedValue.toLowerCase(); | ||
return pastedValue.replace("mailto:", ""); | ||
}, | ||
definitions: { | ||
"*": { | ||
validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5!#$%&'*+/=?^_`{|}~-]" | ||
}, | ||
"-": { | ||
validator: "[0-9A-Za-z-]" | ||
} | ||
}, | ||
onUnMask: function (maskedValue, unmaskedValue, opts) { | ||
return maskedValue; | ||
}, | ||
inputmode: "email" | ||
}, | ||
"mac": { | ||
mask: "##:##:##:##:##:##" | ||
}, | ||
//https://en.wikipedia.org/wiki/Vehicle_identification_number | ||
// see issue #1199 | ||
"vin": { | ||
mask: "V{13}9{4}", | ||
definitions: { | ||
"V": { | ||
validator: "[A-HJ-NPR-Za-hj-npr-z\\d]", | ||
casing: "upper" | ||
} | ||
}, | ||
clearIncomplete: true, | ||
autoUnmask: true | ||
}, | ||
//http://rion.io/2013/09/10/validating-social-security-numbers-through-regular-expressions-2/ | ||
//https://en.wikipedia.org/wiki/Social_Security_number | ||
"ssn": { | ||
mask: "999-99-9999", | ||
postValidation: function (buffer, pos, c, currentResult, opts, maskset, strict) { | ||
var bffr = getMaskTemplate.call(this, true, getLastValidPosition.call(this), true, true); | ||
return /^(?!219-09-9999|078-05-1120)(?!666|000|9.{2}).{3}-(?!00).{2}-(?!0{4}).{4}$/.test(bffr.join("")); | ||
} | ||
}, | ||
"cssunit": { | ||
regex: "[+-]?[0-9]+\\.?([0-9]+)?(px|em|rem|ex|%|in|cm|mm|pt|pc)" | ||
}, "url": { //needs update => https://en.wikipedia.org/wiki/URL | ||
regex: "(https?|ftp)://.*", autoUnmask: false, keepStatic: false, tabThrough: true | ||
}, "ip": { //ip-address mask | ||
mask: "i{1,3}.j{1,3}.k{1,3}.l{1,3}", definitions: { | ||
"i": { | ||
validator: ipValidator | ||
}, "j": { | ||
validator: ipValidator | ||
}, "k": { | ||
validator: ipValidator | ||
}, "l": { | ||
validator: ipValidator | ||
} | ||
}, onUnMask: function (maskedValue, unmaskedValue, opts) { | ||
return maskedValue; | ||
}, inputmode: "decimal", substitutes: {",": "."} | ||
}, "email": { | ||
//https://en.wikipedia.org/wiki/Domain_name#Domain_name_space | ||
//https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names | ||
//should be extended with the toplevel domains at the end | ||
mask: function ({separator, quantifier}) { | ||
var emailMask = "*{1,64}[.*{1,64}][.*{1,64}][.*{1,63}]@-{1,63}.-{1,63}[.-{1,63}][.-{1,63}]"; | ||
var mask = emailMask; | ||
if (separator) { | ||
for (let i = 0; i < quantifier; i++) { | ||
mask += `[${separator}${emailMask}]`; | ||
} | ||
} | ||
return mask; | ||
}, | ||
greedy: false, | ||
casing: "lower", | ||
separator: null, | ||
quantifier: 5, | ||
skipOptionalPartCharacter: "", | ||
onBeforePaste: function (pastedValue, opts) { | ||
pastedValue = pastedValue.toLowerCase(); | ||
return pastedValue.replace("mailto:", ""); | ||
}, | ||
definitions: { | ||
"*": { | ||
validator: "[0-9\uFF11-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5!#$%&'*+/=?^_`{|}~-]" | ||
}, "-": { | ||
validator: "[0-9A-Za-z-]" | ||
} | ||
}, | ||
onUnMask: function (maskedValue, unmaskedValue, opts) { | ||
return maskedValue; | ||
}, | ||
inputmode: "email" | ||
}, "mac": { | ||
mask: "##:##:##:##:##:##" | ||
}, //https://en.wikipedia.org/wiki/Vehicle_identification_number | ||
// see issue #1199 | ||
"vin": { | ||
mask: "V{13}9{4}", definitions: { | ||
"V": { | ||
validator: "[A-HJ-NPR-Za-hj-npr-z\\d]", casing: "upper" | ||
} | ||
}, clearIncomplete: true, autoUnmask: true | ||
}, //http://rion.io/2013/09/10/validating-social-security-numbers-through-regular-expressions-2/ | ||
//https://en.wikipedia.org/wiki/Social_Security_number | ||
"ssn": { | ||
mask: "999-99-9999", postValidation: function (buffer, pos, c, currentResult, opts, maskset, strict) { | ||
var bffr = getMaskTemplate.call(this, true, getLastValidPosition.call(this), true, true); | ||
return /^(?!219-09-9999|078-05-1120)(?!666|000|9.{2}).{3}-(?!00).{2}-(?!0{4}).{4}$/.test(bffr.join("")); | ||
} | ||
}, | ||
}); |
@@ -343,3 +343,3 @@ import { | ||
// commandObj.rewritePosition = undefined; | ||
commandObj = true; | ||
commandObj = true; // see prevalidation in isValid | ||
} | ||
@@ -633,3 +633,4 @@ } | ||
for (i = lvp; i >= begin; i--) { | ||
var clearpos = isSelection.call(inputmask, pos) ? begin : validatedPos; | ||
for (i = lvp; i >= clearpos; i--) { | ||
maskset.validPositions.splice(i, 1); | ||
@@ -636,0 +637,0 @@ if (validTest === undefined) delete maskset.tests[i + 1]; |
{ | ||
"name": "inputmask", | ||
"version": "5.0.9-beta.33", | ||
"version": "5.0.9-beta.35", | ||
"description": "Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jqlite.", | ||
@@ -5,0 +5,0 @@ "main": "dist/inputmask.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
12551
975592