<!DOCTYPE html>
<html>
<head>
<title>邮箱注册</title>
<style type="text/css">
td{
text-align: center;
color: blue;
}
textarea{
width: 200px;
height: 100px;
}
</style>
<script type="text/javascript">
function IsEmail(str) {
var reg=/^[\s\S]{6,10}$/;
return reg.test(str);
}
function IsPassword(pw1,pw2){
var reg=/^[a-zA-Z0-9]{6,15}$/;
return (reg.test(pw1)&®.test(pw2)&&(pw1==pw2));
}
function fun1(){
if(!IsEmail(document.getElementById("email").value)){
alert("邮箱名称填写错误或不规范");
document.getElementById("email").focus();
return false;
}
if(!IsPassword(document.getElementById("pw").value,document.getElementById("rpw").value)){
alert("两个密码必须相同且不能为空");
document.getElementById("rpw").focus();
return false;
用js以及正则表达式实现对邮箱和密码的前端验证
最新推荐文章于 2023-12-01 16:36:40 发布