I'm using jquery.inputmask on a text box that is used to collect email addresses and I want to be able to type in upper case letters.
Currently, it converts any upper case letters as you type them to lower case. How can I change it to accept both upper and lower case letters.
JSFiddle:
$(document).ready(function(){
//email mask
$("#u_email").inputmask({
mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
greedy: false,
onBeforePaste: function (pastedValue, opts) {
pastedValue = pastedValue.toLowerCase();
return pastedValue.replace("mailto:", "");
},
definitions: {
'*': {
validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
cardinality: 1,
casing: "lower"
}
}
});
});
From reading the inputmask jquery plugin documentation, there are two things forcing the text input contents to lower case.
The pastedValue = pastedValue.toLowerCase(); changes any copy-pasted text to lowercase.
The casing: "lower" changes any typed text to lowercase.
Removing both of these lines, we are left with the below, which works on your jsfiddle.
$(document).ready(function(){
//email mask
$("#u_email").inputmask({
mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
greedy: false,
onBeforePaste: function (pastedValue, opts) {
return pastedValue.replace("mailto:", "");
},
definitions: {
'*': {
validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
cardinality: 1
}
}
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With