input框输入过之后为什么再没法选中了~
<html>
<head lang="en">
<meta charset="utf-8"/>
<title></title>
<link href="style.css" rel="stylesheet"/>
<script>
window.onload=function() {
var aInput = document.getElementsByTagName('input');
var oName = aInput[0];
var pwd = aInput[1];
var pwd2 = aInput[2];
var aP = document.getElementsByTagName('p');
var nameMsg = aP[0];
var pwdMsg = aP[1];
var pwdMsg2 = aP[2];
var count = document.getElementById('count');
var aEm = document.getElementsByTagName('em');
var name_length=0;
function getLength(str){
return str.replace(/[^\x00-\xff]/ig,'xx').length;
}
oName.onfocus = function () {
nameMsg.style.display='block';
nameMsg.innerHTML='<i></i>5-25个字符,一个汉字为两个字符,推荐使用中文会员名'
};
oName.onkeyup = function () {
count.style.visibility='visible';
name_length=getLength(this.value);
count.innerHTML=name_length+'个字符';
if(name_length==0){
count.style.visibility="hidden";
}
};
oName.onblur = function () {
//含有非法字符
var re=/[^\w\u4e00-\u9fa5]/g;
if(re.test(this.value)){
nameMsg.innerHTML="<i></i>含有非法字符"
}
//不能为空
else if(name_length==0){
nameMsg.innerHTML="<i></i>不能为空"
}
//长度超过25个字符
else if(name_length>25){
nameMsg.innerHTML="<i></i>长度超过二十五个字符"
}
//长度少于6个字符
else if(name_length<6){
nameMsg.innerHTML="<i></i>长度少于6个字符"
}
//ok
else{
nameMsg.innerHTML="<i></i>ok"
}
};
}
</script>
</head>
<body>
<form>
<div><span> 会员名:</span><input type="text" class="text"><p class="meg"><i class="ati"></i>5-25个字符,一个汉字为两个字符,推荐使用中文会员名</p></div>
<div><span> </span><b id="count">0个字符</b></div>
<div><span>登录密码:</span><input type="password" class="text"/><p class="msg"><i class="err"></i>5-25个字符,一个汉字为两个字符,推荐使用中文会员名</p></div>
<div><span> </span><em class="active">弱</em><em>中</em><em>强</em></div>
<div><span>确认密码:</span><input type="password" class="text"/><!--disabled=""--><p>请再输入一次</p></div>
<div><span> 验证码:</span><input type="text" class="text" style="width:50px;"/></div>
<div><span> </span><input class="submitBtn btn" type="submit" value="同意协议并注册"/></div>
</form>
</body>
</html>