react-input-mask
react-input-mask copied to clipboard
how to only allow numbers and uppercase letters?
trafficstars
Hi @sanniassin do you know how to allow only numbers and uppercase letters? When user inputs lowercase, it should automatically converts to uppercase.
This can be implemented using controlled components.
would be great if anyone could provide an example
The way I did it was setting the mask prop to a9a 9a9 and then adding text-transform: uppercase CSS to my input element
I did a bit different. Defined beforeMaskedValueChange like so:
beforeMaskedValueChange = function(newState) {
newState.value = newState.value.toUpperCase();
return newState;
};
Not sure is it the best possible solution for this case, but it worked for me so far.