⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 check.js

📁 主要是航空预订系统
💻 JS
字号:
/* 
用途:检查输入字符串是否只由英文字母和数字组成 
输入: 
s:字符串 
返回: 
如果通过验证返回true,否则返回false 

*/ 
function isNumberOrLetter( username ){
	var regu = "^[0-9a-zA-Z]+$"; 
	var re = new RegExp(regu); 
	if (re.test(username)) { 
		return true; 
	}else{ 
		return false; 
	} 
} 

function checkUserName(){
	var username = document.getElementById( "username" );
	if( username.value.length>=6 && username.value.length<=20 ){
		if( isNumberOrLetter( username.value ) == false ){
        	document.getElementById("usernamediv").innerHTML="用户名不符合要求";
        	return false;
		}
	}else{
		document.getElementById("usernamediv").innerHTML="用户名不符合要求";
		return false;
	}
	document.getElementById("usernamediv").innerHTML="";
	return true;
}

function checkPassword(){
	var password = document.getElementById( "password" );
	if( password.value.length>=6 && password.value.length<=10 ){
		if( isNumberOrLetter( password.value ) == false ){
        	document.getElementById("passworddiv").innerHTML="密码不符合要求";
        	return false;
		}
	}else{
		document.getElementById("passworddiv").innerHTML="密码不符合要求";
		return false;
	}
	document.getElementById("passworddiv").innerHTML="";
	var configPassword = document.getElementById( "configpassword" );
	if( configPassword.value.length!=0 ){
		if( configPassword.value != password.value ){
			document.getElementById("configpassworddiv").innerHTML="两次输入密码不一致";
			return false;
		}else{
			document.getElementById("configpassworddiv").innerHTML="";
		}
	}
	return true;
}

function checkConfigPassword(){
	var password = document.getElementById( "password" );
	if( isNumberOrLetter( password.value ) == true ){
		var password1 = document.getElementById( "password" );
		var password2 = document.getElementById( "configpassword" );
		if( password1.value != password2.value ){
	        document.getElementById("configpassworddiv").innerHTML="两次输入密码不一致";
	        return false;
		}else{
			document.getElementById("configpassworddiv").innerHTML="";
		}
	}
	return true;
}
function checkName(){
	var name = document.getElementById( "name" );
	if( name.value.length == 0 ){
		document.getElementById("chinanamediv").innerHTML="中文名不能为空";
		return false;
	}else{
		document.getElementById("chinanamediv").innerHTML="";
	}
	return true;
}
function checkCertificationCode(){
	var certificationCode = document.getElementById( "certificationCode" );
	if( certificationCode.value.length == 0 ){
		document.getElementById("certificationcodediv").innerHTML="证件号码不能为空";
		return false;
	}else{
		document.getElementById("certificationcodediv").innerHTML="";
	}
	return true;
}

function register(){
	var c1 = checkUserName();
	var c2 = checkPassword();
	var c3 = checkConfigPassword();
	var c4 = checkName();
	var c5 = checkCertificationCode();
	if(c1&&c2&&c3&&c4&&c5){
		return true;
	}
	return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -