注册 登录 充值会员 退出
联系客服 毕业设计 java源码 PHP源码
充值

手机端注册表单验证js代码

作者/代码整理:  (源码已亲测,不会安装的可以向QQ1915635791要安装视频教程) 发布日期:2023-05-06
手机端注册表单验证js代码
一款简单好用的手机端注册表单验证js代码,js用户名密码手机发送验证码表单验证代码下载。


js代码

<script type="text/javascript">
	function checkreg() {
		var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
		if(document.form1.name.value == "") {
			//alert("请输入您的用户名!");
			document.getElementById("tish").innerHTML = "<font color='red'>请输入您的用户名!</font>";
			form1.name.focus();
			return false;
		}
		document.getElementById("tish").innerHTML = "<font color='green'>正确</font>";
		//          if (document.form1.User.value.length<4 || document.form1.User.value.length>15)
		// {
		//  alert("用户名长度限制在4-15位!");
		//  form1.User.focus();
		//  return false;
		// }
		if(document.form1.password.value == "") {
			//alert("请输入密码!");
			document.getElementById("ts").innerHTML = "<font color='red'>请输入密码</font>";
			form1.password.focus();
			return false;
		}
		if(document.form1.password.value.length < 6 || document.form1.password.value.length > 20) {
			//alert("密码长度限制在6-20位!");
			document.getElementById("ts").innerHTML = "<font color='red'>密码长度限制在6-20位!</font>";
			form1.password.focus();
			return false;
		}
		document.getElementById("ts").innerHTML = "<font color='green'>正确</font>";
		if(document.form1.password.value != document.form1.Pwdagain.value) {
			document.getElementById("tishi").innerHTML = "<font color='red'>两次密码不相同</font>";
			form1.password.focus();
			return false;
		}
		document.getElementById("tishi").innerHTML = "<font color='green'>正确</font>";
		//   alert("注册成功!");
		// location.href="http://www.lanrenzhijia.com"; 

		if(!myreg.test(document.form1.phone.value)) {
			document.getElementById("tss").innerHTML = "<font color='red'>手机号码错误</font>";
			form1.password.focus();
			return false;
		}
		document.getElementById("tss").innerHTML = "<font color='green'>正确</font>";
		if(document.form1.code.value == "") {
			
			 document.getElementById("tsi").innerHTML = "<font color='red'>验证码不能为空</font>";
			form1.code.focus(); 
			return false;
		}
		document.getElementById("tsi").innerHTML = "<font color='green'>正确</font>";
		location.href="homepage.html";
	}

	function sendMessage(t) {
		var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
		if(!myreg.test(document.form1.phone.value)) 
		{
		 alert('请输入有效的手机号码!'); 
		  return false; 
		  } //
		document.form1.dynamic.disabled = true;
		for(i = 1; i <= t; i++) {
			window.setTimeout("update_p(" + i + "," + t + ")", i * 1000);
		}

	}

	function update_p(num, t) {
		if(num == t) {
			document.form1.dynamic.value = " 重新发送 ";
			document.form1.dynamic.disabled = false;
		} 
		else {
			printnr = t - num;
			document.form1.dynamic.value = " (" + printnr + ")秒后重发";
		}
	}
</script>

关注公众号,免费赠送安装视频教程、环境和学习视频,后面会不断更新。