JavaScript form verification age
JavaScript form verification age, which determines whether an input amount meets the age, is implemented through regular expressions.
//Check age
function isAge(str){
var mydate=new Date;
var now=mydate.getFullYear();
if (str now-18) {
return false;
return true; email, implemented through regular expressions.
//Check email mailbox
function isEmail(str){
var reg = /^([a-zA-Z0-9_-]) @([a-zA-Z0-9_-]) ((.[a-zA-Z0-9_-]{2,3}){1,2})$/; return reg.test(str); }
JavaScript form verification Chinese capital letters
JavaScript form verification Chinese capital letters, determine whether an input is Chinese or capital English letters, implemented through regular expressions.
//Check whether it is a valid real name, which can only contain Chinese or uppercase English letters
function isValidTrueName(strName){ var str = Trim(strName); //Determine whether it is All English uppercase or all Chinese, can contain spaces var reg = /^[A-Z u4E00-u9FA5] $/;
if(reg.test(str)){
return false;
}
return true;
}
JavaScript form verification is Chinese
JavaScript form verification is Chinese, to determine whether an input is Chinese, implemented through regular expressions.
//Check if it is Chinese
function isChn(str){
var reg = /^[u4E00-u9FA5] $/;
if(!reg.test(str)) {
return false;
return true; Phone number, implemented through regular expressions.
//Check phone number
function isTel(str){
var reg=/^([0-9]|[-]) $/g;
if(str.length
18){
return false;
}
else{
return reg.exec(str); } }
Statement of this Website
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