Home  >  Article  >  Web Front-end  >  javascript limit input script collection_javascript skills

javascript limit input script collection_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:42:431353browse

1. Only Chinese characters can be input


2. Only numbers can be input:

Simple prohibition of inputting Chinese characters

Input Numbers and decimal points:
onkeyup="value=value.replace(/[^d{1,}.d{1,}|d{1,}]/g,'')"
javascript only Enter numbers and ":".2007-11-24 15:50
Only numbers and ":" can be used, for example, when entering time.

Only letters and equal signs can be entered, but Chinese characters cannot be entered.
Other things:
Script javascript that can only input numbers- -
1.onafterpaste="this.value=this.value.replace(/D/g,'')">
The first half of the sentence means that keyboard typing can only be numbers, and the second half of the sentence means that pasting can only be numbers
2.
3.
JavaScript restricts input to numbers and English only - -
function isregname( checkobj)
{
var checkOK = "0123456789-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var checkStr = checkobj;
var allValid = true;
var decPoints = 0;

for (i = 0; i {
ch = checkStr.charAt(i);
for (j = 0; j if (ch == checkOK.charAt(j))
break;
if (j == checkOK.length)
{
allValid = false;
break;
}
}
return (allValid)
}
- ---------------
if(!(isregname(obj.loginname.value))){
alert("[Member code] does not meet the specifications, the member code only Can be English letters or numbers");
obj.loginname.focus();
return(false);
}
if(!(isregname(obj.password.value))){
alert("[Password] does not meet the specifications, the password can only be English letters or numbers");
obj.password.focus();
return(false);
}

4. JavaScript can only input English and numbers into the input box

5. You can use Javascript to check the text box and filter out non-0-9 characters.


 
[url=http://blog.csdn.net/xujh/admin/EditPosts.aspx][/url]

6. Limited to Only the IP address format can be entered in the text box








IP address input


Enter the IP address

.
.
.



7. Date control that limits the input format
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn