by zhangxinxu 2009-12-12 19:05

密码输入错误后的自动选中密码

请输入错误密码:例如123

var obj = { pwd: document.getElementById("zxxPwdTest"), btn: document.getElementById("zxxSureBtn"), rem: document.getElementById("zxxRemind"), reg: /^\w{6,20}$/ }; obj.btn.onclick = function(){ //正则判断 if(!obj.reg.test(obj.pwd.value)){ obj.rem.style.color = "#ff3300"; obj.rem.innerHTML = "密码不正确"; obj.pwd.focus(); obj.pwd.select(); }else{ obj.rem.style.color = "#999999"; obj.rem.innerHTML = "请输入错误密码便于测试"; } return false; }