Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restricting character set in a Textinput field

I have a TextInput field that should be restricted to either capital letters, lowercase letters, numbers and underscores. This is the code I'm trying to use to restrict characters:

restrict="\\A-Z\\a-z\\0-9\\ \\_\\-"

I'm using MXML for this Textinput component.

Unfortunately this does not restrict the \ character, which is the last character I'd like to restrict.

How can I add the backslash to the list of restricted characters?

Thanks

Stephen

like image 221
StephenAdams Avatar asked Jan 16 '12 15:01

StephenAdams


People also ask

How do I limit a character in input field?

The HTML <input> tag is used to get user input in HTML. To give a limit to the input field, use the min and max attributes, which is to specify a maximum and minimum value for an input field respectively. To limit the number of characters, use the maxlength attribute.

How do you restrict characters in input field react?

Approach 1: Using maxLength: We will use maxLength attribute for our input. It is the same as the maxlength attribute used for HTML. It restricts the user to enter characters till it reaches the maxLength limit that we have set.


1 Answers

Actually found the solution I've amended the restrict code to:

restrict="A-Za-z0-9 _\-"

I took out all the back slashes which I thought or was using as delimiters.

Works fine now.

like image 152
StephenAdams Avatar answered Sep 29 '22 19:09

StephenAdams