Home >
Web Front-end >
JS Tutorial >
Summary of common JavaScript verification function examples_javascript skills
Summary of common JavaScript verification function examples_javascript skills
WBOY
Release: 2016-05-16 16:30:16
Original
1407 people have browsed it
The examples in this article summarize common JavaScript verification functions. Share it with everyone for your reference. The specific summary is as follows:
//Function name: fucCheckNUM
//Function introduction: Check whether it is a number
//Parameter description: Number to be checked
//Return value: 1 means it is a number, 0 means it is not a number
function fucCheckNUM(NUM)
{
var i,j,strTemp;
strTemp="0123456789";
if (NUM.length== 0)
return 0
for (i=0;i
{
j=strTemp.indexOf(NUM.charAt(i));
if (j==-1)
{
//Explain that there are characters that are not numbers
return 0;
}
}
//The description is a number
return 1;
}
//Function name: fucCheckTEL
//Function introduction: Check whether it is a phone number
//Parameter description: String to be checked
//Return value: 1 means legal, 0 means illegal
function fucCheckTEL(TEL)
{
var i,j,strTemp;
strTemp="0123456789-()# ";
for (i=0;i
{
j=strTemp.indexOf(TEL.charAt(i));
if (j==-1)
{
//Indicates that some characters are illegal
return 0;
}
}
//Explanation is legal
return 1;
}
7. Function to determine whether the input is Chinese
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