<input type= ' text ' id= ' sys_page_jumppage ' name= ' sys_page_jumppage ' size= ' 3 ' maxlength= ' 5 ' onkeyup= ' this.value= This.value.replace (/[^1-9]\d*$/, "") ' ondragenter= "return false" Onpaste= "return!clipboarddata.getdata (' text '). Match (/\d/) "" style= "ime-mode:disabled;" >
1. Enter only numbers and English:
<input onkeyup= "Value=value.replace (/[\w]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') "id=" Text1 "name=" Text1 ">
2. Only numbers can be entered:
<input onkeyup= "Value=value.replace (/[^\d]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ') "id=" Text2 "name=" Text2 ">
3. Only full-width input:
<input onkeyup= "Value=value.replace (/[^\uff00-\uffff]/g, ')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\uff00-\uffff]/g, ') "id=" Text3 "name=" Text3 ">
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, ') "id=" Text4 "name=" TEXT4 ">
5. Email Address verification:
var Regu = "^ (([0-9a-za-z]+) | ( [0-9a-za-z]+[_.0-9a-za-z-]*[0-9a-za-z]+) @ ([a-za-z0-9-]+[.]) + ([a-za-z]{2}|net|net|com|com|gov|gov|mil|mil|org|org|edu|edu|int|int) $ "
var re = new RegExp (Regu);
if (S.search (re)! =-1) {
return true;
} else {
Window.alert ("Please enter a valid legal e-mail address!") ")
return false;
}
6. Identity card:
"^\\d{17} (\\d|x) $"
7.17 Regular Expressions
"^\\d+$"//nonnegative integer (positive integer + 0)
"^[0-9]*[1-9][0-9]*$"//Positive integer
"^ ((-\\d+) | (0+)) $ "//non-positive integer (negative integer + 0)
"^-[0-9]*[1-9][0-9]*$"//Negative integer
"^-?\\d+$"//Integer
"^\\d+ (\\.\\d+)? $"//non-negative floating-point number (positive floating point + 0)
^ ([0-9]+\\]. [0-9]*[1-9][0-9]*) | ([0-9]*[1-9][0-9]*\\. [0-9]+) | ([0-9]*[1-9][0-9]*)) $ "//positive floating-point number
"^ ((-\\d+ (\\.\\d+)?) | (0+ (\\.0+)?)) $ "//non-positive floating-point number (negative floating-point number + 0)
^ (-([0-9]+\\]. [0-9]*[1-9][0-9]*) | ([0-9]*[1-9][0-9]*\\. [0-9]+) | ([0-9]*[1-9][0-9]*))) $ "//negative floating-point number
^ (-?\\d+) (\\.\\d+)? $ "//floating-point number
"^[a-za-z]+$"//A string consisting of 26 English letters
"^[a-z]+$"//A string consisting of 26 uppercase letters in English
"^[a-z]+$"//String consisting of 26 English letters in lowercase
"^[a-za-z0-9]+$"//string consisting of a number and 26 English letters
"^\\w+$"//A string consisting of numbers, 26 letters or underscores
"^[\\w-]+ (\\.[ \\w-]+) *@[\\w-]+ (\\.[ \\w-]+) +$ "//email address
"^[a-za-z]+://(\\w+ (-\\w+) *) ( \\w+ (-\\w+) *) * (\\?\\s*)? $ "//url
=============================================
1. The dashed box when the button is pressed
Add attribute value Hidefocus or hidefocus=true in input
2. Read-only text box contents
Add the attribute value in input readonly
3. Prevent the text document from being emptied (you can use the style content as a class reference)
<input Style=behavior:url (#default #savehistory); Type=text id=opersistinput>
4.ENTER key to move the cursor to the next input box
<input onkeydown= "if (event.keycode==13) event.keycode=9" >
5. Only Chinese (with flashing)
<input onkeyup= "value="/value.replace (/["-~]/g,") "onkeydown=" if (event.keycode==13) event.keycode=9 ">
6. Only digital (with flashing)
<input onkeyup= "value="/value.replace (/["^\d]/g,") "Onbeforepaste=" Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ')) ">
7. Only digital (no flashing)
<input ime-mode:disabled "onkeydown=" if (event.keycode==13) event.keycode=9 "onkeypress=" if ((event.keyCode<48 || event.keycode>57)) Event.returnvalue=false ">
8. Only input English and numerals (with flashing)
<input onkeyup= "value="/value.replace (/[\w]/g, "')" onbeforepaste= "Clipboarddata.setdata (' text ', Clipboarddata.getdata (' text '). Replace (/[^\d]/g, ')) ">
9. Shielding Input Method
<input type= "text" name= "url" ime-mode:disabled "onkeydown=" if (event.keycode==13) event.keycode=9 ">
10. Enter only digits, decimal point, minus (-) character (no flashing)
<input onkeypress= "if (event.keycode!=46 && event.keycode!=45 && (event.keycode<48 | | event.keycode>57)) Event.returnvalue=false ">
11. Only two decimal places can be entered, three decimal places (with flashing)
<input maxlength=9 onkeyup= "if (Value.match (/^\d{3}$/)) value="/value.replace (Value,parseint (VALUE/10)) "; value= "/value.replace (/\.\d*\./g, '." ') "onkeypress=" if ((event.keycode<48 | | event.keycode>57) && event.keycode!=46 && event.keycode!=45 | | Value.match (/^\d{3}$/) | | /\.\d{3}$/.test (value)) {Event.returnvalue=false} "Id=text_kfxe name=text_kfxe>
Source: Cheng Pipe network, this article link: http://www.cgner.com/web/js/201403_177.html
"Turn" 17 kinds of commonly used JS regular expression non-negative floating point number negative positive number.