This article is a mirror article of machine translation, please click here to jump to the original article.

View: 19610|Reply: 0

[Source] The text box only allows numbers to be entered

[Copy link]
Posted on 4/16/2015 11:25:56 PM | | |

<input type="text" name="test" > <br />
<input name="test1" type="text" >
There is a difference between using Up and Down
You can only enter numbers, letters, and underscores
<input ID="txtShopNumber" runat="server" class="input_text" maxlength="8"/>
Commonly used regular expressions can only enter numbers: "^[0-9]*$"
Only n-digit numbers can be entered: "^\d{n}$"
Only enter at least n digits: "^\d{n,}$"
Only numbers in the m-n digit can be entered: "^\d{m,n}$"
Only numbers starting with zero and non-zero can be entered: "^(0|[ 1-9][0-9]*)$”
Only positive real numbers with two decimal places can be entered: "^[0-9]+(.[ 0-9]{2})?$”
Only positive real numbers with 1-3 decimal places can be entered: "^[0-9]+(.[ 0-9]{1,3})?$”
Only non-zero positive integers can be entered: "^\+? [1-9] [0-9]*$”
Only negative integers that are not zero can be entered: "^\-[1-9][0-9]*$"
Only characters of length 3 can be entered: "^. {3}$”
Only a string of 26 letters can be entered: "^[A-Za-z]+$"
Only a string consisting of 26 uppercase letters can be entered: "^[A-Z]+$"
Only a string of 26 lowercase letters can be entered: "^[a-z]+$"
Only a string consisting of numbers and 26 letters can be entered: "^[A-Za-z0-9]+$"
You can only enter a string consisting of numbers, 26 letters, or an underscore: "^\w+$"
Verify user password: "^[a-zA-Z]\w{5,17}$" The correct format is: starting with a letter and between 6-18 in length,
Only characters, numbers, and underscores can be included.
Verify whether it contains ^%&'; =?$\", etc.: "[^%&',; =?$\x22]+”
You can only enter Chinese characters: "^[\u4e00-\u9fa5],{0,}$"
Verify email address: "^\w+[-+.] \w+)*@\w+([-.] \w+)*\.\w+([-.] \w+)*$”
Verify the Internet URL:"^http://([\w-]+\.) +[\w-]+(/[\w-./?%&=]*)?$”
Verified phone number: "^(\d3,4|\d{3,4}-)?\d{7,8}$"
The correct format is: "XXXX-XXXXXXXXX", "XXXX-XXXXXXX", "XXX-XXXXXXX",
“XXX-XXXXXXXX”,“XXXXXXX”,“XXXXXXXX”。
Verify ID Number (15 or 18 digits): "^\d{15}|\d{}18$"
12 months of validation for a year: "^(0?[ 1-9]|1[0-2])$" is correctly formatted: "01"-"09" and "1""12"
31 days of verification for a month: "^((0?[ 1-9])| ((1|2)[0-9])|30|31)$”
The correct format is: "01", "09" and "1" "31".

Use regular expressions to limit text boxes to enter numbers, decimal points, English letters, Chinese characters, and other codes

1. The text box can only enter the numeric code (decimal points cannot be entered either)
<input>
2. Only numbers can be entered, and decimal points can be entered.
<input>
<input name=txt1>
3. Number and decimal point method two
<input type=text t_value="" o_value="">
4. Only letters and kanji can be entered
<inputonbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[\d]/g,''))" maxlength=10 name="Numbers">
5. Only English letters and numbers can be entered, not Chinese
<input>
6. Only enter numbers and English<font color="Red">chun</font>
<input>
7. There can only be a maximum of two digits after the decimal point (numbers, both Chinese can be entered), and letters and operator symbols cannot be entered:
<input>
8. There can only be up to two digits after the decimal point (numbers, letters, and Chinese can be entered), and you can enter the operator symbol:
<input>




Previous:Regular Expression Online Auto Generator
Next:ASP.NET of Anti-SQL injection
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com