{
    分享网正式开通,我们为大家提供免费资源,欢迎大家踊跃投稿!

手机端注册表单验证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>


在线预览
资源均来自第三方,谨慎下载,前往第三方网站下载


爱资源分享网 , 版权所有丨本站资源仅限于学习研究,严禁从事商业或者非法活动!丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:手机端注册表单验证js代码
喜欢 ()分享 (0)