<form method="post"> <input type="email" name="" id="email" placeholder="请输入邮箱账号"> <input type="password" name="" id="password" placeholder="设置密码"> <input type="password" name="" id="passwordRepeat" placeholder="确认密码"> <input type="text" name="" id="tel" placeholder="请输入手机号"> </form> <input type="checkbox" id="reader-me">选中表示您同意《法国红酒》 <input type="submit" οnclick="mr_verify()" value="注册" class="mr-btn mr-btn-primary mr-btn-sm mr-fl">
验证邮件格式:
apos=email.value.indexOf("@") dotpos=email.value.lastIndexOf(".") if(apos<1||dotpos-apos<2){ alert("邮箱格式错误!"); } else{ alert("邮箱格式正确") } 验证手机号位数: if(isNaN(tel.value)){ alert("输入数字!"); return; } if(tel.value.length!==11){ alert("错误!手机号是11个数字"); return; }