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 will 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 (' Input number only '); 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;elsethis.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;elsethis.t_value=this.value;if (This.value.match ("/^" (?: [\+\-]?\d+ (?: \. \d+)?)? $/)) This.o_value=this.value "onblur=" if (!this.value.match (?: [/^ (?: \). \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. Only enter numbers 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), 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. Only a maximum of two digits after the decimal point (numbers, letters, Chinese can be entered), you can enter the operation symbol:
<inputonkeyup= "This.value=this.value.replace (/^ (\-) * (\d+) \. ( \d\d). *$/, ' $1$2.$3 ') ">
How to use JS regular expression to determine whether the input box is in Chinese or English numbers, or three mixed:
1. Enter only numbers and English:
<input onkeyup= "Value=value.replace (/[\w]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ')) ">
2. Only numbers can be entered:
<input onkeyup= "Value=value.replace (/[^\d]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ')) ">
3. Only full-width input:
<input onkeyup= "Value=value.replace (/[^\uff00-\uffff]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\uff00-\uffff]/g, ')) ">
4. Only the Chinese characters can be entered:
<input onkeyup= "Value=value.replace (/[^\u4e00-\u9fa5]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\u4e00-\u9fa5]/g, ')) ">
You can also do this:
<input type=text name= Caolig value = "onblur=" if (! ( /^[\d]+\.? \d*$/.test (This.value)) {alert (' Your input is wrong '); this.value= "; This.focus ();}" >
5>.
text box can only input specific words and text boxes can not right-click bullets
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"Http://www.w3.org/TR/html4/loose.dtd" >
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Untitled Document </title>
<body>
Only numbers can be entered
<br>
<input name= "text" type= "text" id= "NewPage"
Onkeyup= "This.value=this.value.replace (/\d/g, ')"
Onafterpaste= "This.value=this.value.replace (/\d/g, ')" >
<br>
Only English and numbers can be entered
<br>
<input name= "Text1" maxlength= "onkeyup=" Value=value.replace (/[^a-za-z0-9]/g, ') "onmouseover=" value= Value.replace (/[^a-za-z0-9]/g, ') "onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^a-za-z0-9]/g, ')) ">
<br>
You can only enter Chinese
<br>
<input type= "text" onkeyup= "Value=value.replace (/[^\u4e00-\u9fa5]/g, ')" >
<br>
<br>
Experimental success
<br> can only enter numbers <br>
<input type=textonkeyup= "This.value=this.value.replace (/\d/g, ')" >
<br> can only enter numbers <br>
<input type= "text" onkeyup= "Value=value.replace (/\d/g, ')" >
<br> can only be entered in uppercase and lowercase English <br>
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z]/g, ')" >
<br> can only enter size to set English and digital <br>
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z0-9]/g, ')" >
<br> can only input Chinese <br>
<input type= "text" onkeyup= "Value=value.replace (/[^\u4e00-\u9fa5]/g, ')" >
<br> can only enter the size of Chinese, English and digital and @ symbols and. Symbols <br>
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z0-9\u4e00-\u9fa5\@\.] /g, ') ' >
<br> only allow input size in English, and can not paste or pop-up paste menu <br/>
<input type= "text" onkeyup= "Value=value.replace (/[^\a-\z\a-\z]/g, ')" onkeydown= "Fnckeystop (event)" Onpaste= " return false "OnContextMenu =" return false "/>
<br><br>
Only numbers and dot numbers can be entered (note: in [^\d\.] D cannot be written in uppercase D, otherwise it will not get the desired effect)
<input name= "Price" type= "text" size= "8" maxlength= "8" onkeyup= "Value=value.replace (/[^\d\.] /g, ') ' >
All in all: First enter onkeyup= "Value=value.replace (/[^\x]/g,") in <input> and then X in (/[\x]/g, ") to the code you want to enter, Chinese u4e00-u9fa5 Digit D English a-z\a-z other symbols @, dots or other symbols. You can also have more than one, separated by the line. For example, in Chinese and English and the number plus the sign symbol \a-\z\a-\z0-9\u4e00-\u9fa5\@\.
If you want to not right-click the popup menu in the text box and cannot paste in the copied information
Enter onkeydown= "Fnckeystop (event)" onpaste= "return false" oncontextmenu= "return false" in <input>. "
</body>
function Blur_email ()
{
var myregemail =/^ ([a-za-z0-9]+[_|\_|\.]?) *[a-za-z0-9][email protected] ([a-za-z0-9]+[_|\_|\.]?) *[a-za-z0-9]+\. [A-za-z] {2,3}$/;//Verify Mailbox
Start verifying whether the message format is.
var Textemail=document.getelementbyid ("Control Name"). Value;
if (Myregemail.test (TextEmail) ==false)
{
Wrong e-mail address;
Alert ("Your mailbox format is wrong");
}
}
Web page text and input control