Javascript USES the canonical control input input box to allow the input of the value method daqo
- 2020-03-30 03:25:25
- OfStack
1. Only Numbers are allowed
<input name="username" type="text" onkeyup="value=this.value.replace(/D+/g,'')">
2. Only letters, Numbers and underscores are allowed (the following two methods are implemented)
<input name="username" type="text" style="ime-mode:disabled">
<input name="username" type="text" onkeyup="value=value.replace(/[^w./]/ig,'')">
3. Only letters, Numbers and =@# are allowed
<input name="username" type="text" onkeyup="value=value.replace(/[^w=@#]|_/ig,'')">
4. Only capital letters and Numbers are allowed
<input name="name" type="text" value=" Type only capital letters and Numbers " style="color:gray" onfocus="this.value='';this.style.color='black'" onkeyup="this.value=this.value.replace(/[^A-Z0-9]/gi,'');this.value=this.value.toLocaleUpperCase();
5. Only Chinese characters are allowed
<input name="username" type="text" onkeyup="value=value.replace(/[^u4E00-u9FA5]/g,'')">
[filter text input]
TextField.restrict = " Here is the input content ";
field.restrict = "^ Here is the content of the prohibited input ";
Let the restrict character contain letters with special meanings (for example - and ^):
field.restrict = "0-9\-"; //Allow Numbers and dashes
field.restrict = "0-9\^"; //Allow Numbers and alpha
field.restrict = "0-9\\"; // Allow Numbers and backslashes
You can also use Unicode to escape sequences, specifying what is allowed. For example:
field.restrict = "^u001A";
Note :ActionScript is case-sensitive, and if the restrict property is set to ABC, it allows the uppercase form of the letters (A,B, and C) to be lowercase when entered, and vice versa.