问题
Im using jquery inputmask
How can I use below code to any input text with out a mask? any letter inputted will force to uppercase.
Inputmask.extendAliases({
uppercase: {
mask: '' // any letters
definitions: {
'*': {
casing: "upper" //
}
}
});
js
$('.uppercase').inputmask({casing:'upper'});
$('.lowercase').inputmask({casing:'lower'});
html
<input type="text" class="uppercase" />
<input type="text" class="lowercase" />
回答1:
.uppercase {
text-transform: uppercase;
}
.lowercase {
text-transform: lowercase;
}
.capitalize {
text-transform: capitalize;
}
<input class="uppercase" />
<input class="lowercase" />
<input class="capitalize" />
Use css.
回答2:
You can use @guradio css and just uppercase results on form submit on serverside or with JavaScript before submit.
Or just read https://github.com/RobinHerbots/Inputmask there examples, you can use regexp to limit only to uppercase letters.
来源:https://stackoverflow.com/questions/42499481/jquery-inputmask-casing-uppercase-lowercase