The text box only agrees to enter a number. net/javascript
<input type= "text" name= "test" onkeyup= "test1.value= (This.value=this.value.replace (/\d/g,"). Substring (0,6)). SUBSTRING (0,3) "> <br/>
<input name= "Test1" type= "text" >
Use up and down are different
Can only enter numbers, letters, underscores
<input id= "Txtshopnumber" runat= "Server" class= "Input_text" maxlength= "8" onkeyup= "Value=value.replace (/[^ (\-) \w \.\/]/ig, ') '/>
Regular expressions that are often used can only enter numbers: "^[0-9]*$"
Only n digits can be entered: "^\d{n}$"
Can only enter at least n digits: "^\d{n,}$"
can only enter m-n digits: "^\d{m,n}$"
You can only enter numbers starting with 0 and non-0: "^ (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})? $ "
Can only enter a nonzero positive integer: "^\+?" [1-9] [0-9]*$]
Can only enter a non-zero negative integer: "^\-[1-9][0-9]*$"
Only characters with a length of 3 can be entered: "^. {3}$ "
Can only enter a string of 26 English letters: "^[a-za-z]+$"
Can only enter a string consisting of 26 uppercase English letters: "^[a-z]+$"
Can only enter a string consisting of 26 lowercase English letters: "^[a-z]+$"
Can only enter a string consisting of a number and 26 English letters: "^[a-za-z0-9]+$"
Can only enter a string consisting of a number, 26 letters or underscores: "^\w+$"
Verify user password: "^[a-za-z]\w{5,17}$" is in the correct format: start with a letter, the length is between 6-18,
Only characters, numbers, and underscores can be included.
Verify that it contains ^%& ',; =?$\ "characters:" [^%& ',; =?$\x22]+ "
Can only input Chinese characters: "^[\u4e00-\u9fa5],{0,}$"
Verify email Address: "^\w+[-+." \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$ "
Verify InternetURL: "^http://([\w-]+\.) +[\w-]+ (/[\w-./?%&=]*)? $ "
Verify the phone number: ^ (\ (\d{3,4}\) |\d{3,4}-)?
\d{7,8}$ "
The correct format is: "Xxxx-xxxxxxx", "xxxx-xxxxxxxx", "xxx-xxxxxxx".
"Xxx-xxxxxxxx". "XXXXXXX", "XXXXXXXX".
Verify the Social Security number (15-bit or 18-digit number): "^\d{15}|\d{}18$"
Validation 12 months of the year: "^ (0?
[1-9]|1[0-2]) $ "correct format:" 01 "-" 09 "and" 1 "" 12 "
Verify one months of 31 days: "^ ((0?[ 1-9]) | ((1|2) [0-9]) |30|31) $ "
The correct format is: "01" "09" and "1" "31".
Using the regular table to limit the text box can only enter numbers, decimal points, English letters, Chinese characters and other types of code
1. Text box can only enter a numeric code (the decimal point can not be entered)
<input onkeyup= "This.value=this.value.replace (/\d/g, ')" onafterpaste= "This.value=this.value.replace (/\D/g, ' ) ">
2. Only the number can be entered and the decimal point can be lost.
<input onkeyup= "if (IsNaN (value)) ExecCommand (' Undo ')" Onafterpaste= "if (IsNaN (value)) ExecCommand (' Undo ')" >
<input name=txt1 onchange= "if (/\d/.test (this.value)) {alert (' can only enter a number '); this.value= ';}" >
3. Number and decimal method two
<input type=text t_value= "" o_value= "" onkeypress= "if (!this.value.match.? \d*?$/)) This.value=this.t_value;else this.t_value=this.value;if (This.value.match (/^ (?
:[\+\-]?
\d+ (?
: \.\d+)?)?
$/) This.o_value=this.value "onkeyup=" if (!this.value.match (/^[\+\-]?
\d*?\.? \d*?$/)) This.value=this.t_value;else this.t_value=this.value;if (This.value.match (/^ (?
: [\+\-]?\d+ (?: \. \d+)?
)?
$/)) This.o_value=this.value "onblur=" if (!this.value.match (?
:[\+\-]?
\d+ (?: \. \d+)? | \.\d*?)? $/) this.value=this.o_value;else{if (This.value.match (/^\.\d+$/)) this.value=0+this.value;if (This.value.match (/^ \.$/)) This.value=0;this.o_value=this.value} ">
4. Only letters and kanji can be entered
<input onkeyup= "Value=value.replace (/[\d]/g, ')" onbeforepaste= "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 onkeyup= "Value=value.replace (/[^\w\.\/]/ig, ')" >
6. Can only input digital and English <font color= "Red" >chun</font>
<input onkeyup= "Value=value.replace (/[^\d|chun]/g, ')" >
7. Only a maximum of two digits after the decimal point (numeric, Chinese can be entered), you can not enter letters and operation symbols:
<input onkeypress= "if ((event.keycode<48 | | event.keycode>57) && event.keycode!=46 | |/\.\d\d$/.test ( Value)) Event.returnvalue=false ">
8. There can only be up to two decimal points (numbers, letters, Chinese can be entered), operators can enter:
<input onkeyup= "This.value=this.value.replace (/^ (\-) * (\d+) \. ( \d\d). *$/, ' $1$2.$3 ') ">
text box only agrees to enter a number