Open Heirema opened 8 years ago
Just use CSS to do so :)
The "text-transform:uppercase" is applied to the whole input an not a part of the entry :)
@Heirema what you asked gives me an idea... I'm trying to think generic here... what if you could pass a callback function to this?
Like..
$.jMaskGlobals = {
translation: {
'2': {
pattern: /[A-Z]/,
optional: true,
transform: function(d) {
return d.toUpperCase();
}
},
}
};
Wow !! Would be really better than my way to do for sure. Because it would allow much more possibilities .... Not just for an uppercase I mean :)
Did the transform proposal get implemented? I can't see that it did, and am wondering why this issue is closed.
$('.campo_codver').mask('SSSS.SSSS.SSSS', {
'translation': {
S: {pattern: /[A-Za-z0-9]/}
},
onKeyPress: function (value, event) {
event.currentTarget.value = value.toUpperCase();
}
});
@Heirema what you asked gives me an idea... I'm trying to think generic here... what if you could pass a callback function to this?
Like..
$.jMaskGlobals = { translation: { '2': { pattern: /[A-Z]/, optional: true, transform: function(d) { return d.toUpperCase(); } }, } };
Hi! Great idea but isn't implemented at this time :disappointed: but is what I need and I try to suggest this simple solution:
while (check()) {
var maskDigit = mask.charAt(m),
valDigit = value.charAt(v),
translation = jMask.translation[maskDigit];
if (translation) {
// ++ EMA
if (translation.transform != undefined){
valDigit = translation.transform(valDigit);
}
// -- EMA
if (valDigit.match(translation.pattern)) {
buf[addMethod](valDigit);
if (translation.recursive) {
Just only my two cents :smirk:
@EToniolo Let's try to make this a Pull Request :) Add the code, write some unit tests for it. I can help ;)
@EToniolo Let's try to make this a Pull Request :) Add the code, write some unit tests for it. I can help @igorescobar I'm happy to contribute but, I have no idea how to do it. I can't create a Pull Request, what I do wrong?
@EToniolo these links might be useful: https://github.com/igorescobar/jQuery-Mask-Plugin#unit-tests https://help.github.com/en/articles/creating-a-pull-request
Found this and after some trial and error I found an easy way around for one-stop solution;
if (translation) {
if (!valDigit.match(translation.pattern)) { // If it does not match the mask, try force it to uppercase
valDigit = valDigit.toUpperCase();
}
if (valDigit.match(translation.pattern)) {
Not really an issue, but an enhancement proposal. Let say you set this as translation :+1:
Where a new pattern option is available : uppercase
This changement then in 'behaviour' :
allow users to not care about cap lock status :wink: Very usefull for fast and "blind entry" ...