怎么用javascript判断2次密码不一致。。弹窗求具体代码

2025-03-22 09:17:42
推荐回答(2个)
回答1:

var pwd = document.getElementById("upassword").value;
var repwd = document.getElementById("repassword").value;
if (pwd == "") { 这是为空的
} else if (repwd == "") { 重复密码为空的
} else if (pwd != repwd) { 两次输入不相同
}

这里最好用正则表达式或者其他什么方法为javascript加一个trim()方法,把两边空格去掉
用jquery也可以实现

回答2:




















用户名:
密码:
重复密码: