1. Only Chinese characters can be entered
<input onkeyup="value=(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="('text',('text').replace(/[^\u4E00-\u9FA5]/g,''))">
2. Only numbers can be entered
<input onkeyup="value=(/[^\d]/g,'') "onbeforepaste="('text',('text').replace(/[^\d]/g,''))">
Simple prohibition on Chinese characters
<input type="text" style="ime-mode:disabled">
Enter the number and the decimal point:
onkeyup="value=(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"
javascript can only enter numbers and ":".2007-11-24 15:50<input type=text onkeyup="=(/[^\d&:]/g,'')" onblur="=(/[^\d&:]/g,'')" onafterpaste="=(/[^\d&:]/g,'')"/>
Only numbers and ":", for example, can be used when entering time.
<input type=text onkeyup="value=(/[^\w&=]|_/ig,'')" onblur="value=(/[^\w&=]|_/ig,'')" />
You can only enter letters and equal signs, but you cannot enter Chinese characters.
Other things:
Script that can only enter numbers javascript--
<input onkeyup="=(/\D/g,'')" onafterpaste="=(/\D/g,'')">
The first half of the sentence means that the keyboard type can only be numbers, and the second half of the sentence can only be numbers when it is pasted.
<input name=txt1 onchange="if(/\D/.test()){alert('Only enter numbers');='';}">
<input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')">
Limit only digits and English
function isregname( checkobj)
{
var checkOK = "0123456789-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var checkStr = checkobj;
var allValid = true;
var decPoints = 0;
for (i = 0; i < ; i++)
{
ch = (i);
for (j = 0; j < ; j++)
if (ch == (j))
break;
if (j == )
{
allValid = false;
break;
}
}
return (allValid)
}
----------------
if(!(isregname())){
alert("[member code] does not comply with the specifications, the member code can only be in English letters or numbers");
();
return(false);
}
if(!(isregname())){
alert("[password] does not comply with the specifications, the password can only be in English letters or numbers");
();
return(false);
}
Enter only English and numeric input boxes
<input onkeyup="value=(/[\W]/g,'') "onbeforepaste="('text',('text').replace(/[^\d]/g,''))">
5. You can use Javascript to check the text box to filter out non-0-9 characters
<script language="javascript" event="onkeydown" for="document">
if(=='TextBox1')
{
if(!KeyIsNumber())
{
return false;//This sentence is the most critical
}
}
</script>
<script language="javascript">
function KeyIsNumber(KeyCode)
{
//If the input character is between 0-9, or the backspace or DEL key
if(((KeyCode>47)&&(KeyCode<58))||(KeyCode==8)||(KeyCode==46))
{
return true;
}
else
{
return false;
}
}
</script>[url=/xujh/admin/][/url]
6. Restricted to the text box, only the IP address format can be entered.
<HTML>
<head>
<meta http-equiv="Content-Type" content="text/HTML; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="">
<style>
.a3{width:30;border:0;text-align:center}
</style>
<script>
function mask(obj){
=(/[^\d]/g,'')
key1=
if (key1==37 || key1==39)
{ ();
nextip=parseInt((2,1))
nextip=key1==37?nextip-1:nextip+1;
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
if(>=3)
if(parseInt()>=256 || parseInt()<=0)
{
alert(parseInt()+"IP address error!")
=""
()
return false;
}
else
{ ();
nextip=parseInt((2,1))+1
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
}
function mask_c(obj)
{
('text',('text').replace(/[^\d]/g,''))
}
</script>
<title>IP address input</title>
</head>
<body>IP address input
<div style="border-width:1;border-color:balck;border-style:solid;width:165;font-size:9pt">
<input type=text name=ip1 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip2 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip3 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip4 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>
</div>
</body>
</HTML>
Copy the codeThe code is as follows:
<input onkeyup="value=(/[^\u4E00-\u9FA5]/g,'')" onbeforepaste="('text',('text').replace(/[^\u4E00-\u9FA5]/g,''))">
2. Only numbers can be entered
Copy the codeThe code is as follows:
<input onkeyup="value=(/[^\d]/g,'') "onbeforepaste="('text',('text').replace(/[^\d]/g,''))">
Simple prohibition on Chinese characters
Copy the codeThe code is as follows:
<input type="text" style="ime-mode:disabled">
Enter the number and the decimal point:
Copy the codeThe code is as follows:
onkeyup="value=(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')"
javascript can only enter numbers and ":".2007-11-24 15:50<input type=text onkeyup="=(/[^\d&:]/g,'')" onblur="=(/[^\d&:]/g,'')" onafterpaste="=(/[^\d&:]/g,'')"/>
Only numbers and ":", for example, can be used when entering time.
Copy the codeThe code is as follows:
<input type=text onkeyup="value=(/[^\w&=]|_/ig,'')" onblur="value=(/[^\w&=]|_/ig,'')" />
You can only enter letters and equal signs, but you cannot enter Chinese characters.
Other things:
Script that can only enter numbers javascript--
Copy the codeThe code is as follows:
<input onkeyup="=(/\D/g,'')" onafterpaste="=(/\D/g,'')">
The first half of the sentence means that the keyboard type can only be numbers, and the second half of the sentence can only be numbers when it is pasted.
Copy the codeThe code is as follows:
<input name=txt1 onchange="if(/\D/.test()){alert('Only enter numbers');='';}">
<input onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')">
Limit only digits and English
Copy the codeThe code is as follows:
function isregname( checkobj)
{
var checkOK = "0123456789-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var checkStr = checkobj;
var allValid = true;
var decPoints = 0;
for (i = 0; i < ; i++)
{
ch = (i);
for (j = 0; j < ; j++)
if (ch == (j))
break;
if (j == )
{
allValid = false;
break;
}
}
return (allValid)
}
----------------
if(!(isregname())){
alert("[member code] does not comply with the specifications, the member code can only be in English letters or numbers");
();
return(false);
}
if(!(isregname())){
alert("[password] does not comply with the specifications, the password can only be in English letters or numbers");
();
return(false);
}
Enter only English and numeric input boxes
Copy the codeThe code is as follows:
<input onkeyup="value=(/[\W]/g,'') "onbeforepaste="('text',('text').replace(/[^\d]/g,''))">
5. You can use Javascript to check the text box to filter out non-0-9 characters
Copy the codeThe code is as follows:
<script language="javascript" event="onkeydown" for="document">
if(=='TextBox1')
{
if(!KeyIsNumber())
{
return false;//This sentence is the most critical
}
}
</script>
<script language="javascript">
function KeyIsNumber(KeyCode)
{
//If the input character is between 0-9, or the backspace or DEL key
if(((KeyCode>47)&&(KeyCode<58))||(KeyCode==8)||(KeyCode==46))
{
return true;
}
else
{
return false;
}
}
</script>[url=/xujh/admin/][/url]
6. Restricted to the text box, only the IP address format can be entered.
Copy the codeThe code is as follows:
<HTML>
<head>
<meta http-equiv="Content-Type" content="text/HTML; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="">
<style>
.a3{width:30;border:0;text-align:center}
</style>
<script>
function mask(obj){
=(/[^\d]/g,'')
key1=
if (key1==37 || key1==39)
{ ();
nextip=parseInt((2,1))
nextip=key1==37?nextip-1:nextip+1;
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
if(>=3)
if(parseInt()>=256 || parseInt()<=0)
{
alert(parseInt()+"IP address error!")
=""
()
return false;
}
else
{ ();
nextip=parseInt((2,1))+1
nextip=nextip>=5?1:nextip
nextip=nextip<=0?4:nextip
eval("ip"+nextip+".focus()")
}
}
function mask_c(obj)
{
('text',('text').replace(/[^\d]/g,''))
}
</script>
<title>IP address input</title>
</head>
<body>IP address input
<div style="border-width:1;border-color:balck;border-style:solid;width:165;font-size:9pt">
<input type=text name=ip1 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip2 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip3 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>.
<input type=text name=ip4 maxlength=3 class=a3 onkeyup="mask(this)" onbeforepaste=mask_c()>
</div>
</body>
</HTML>