87,907
社区成员
发帖
与我相关
我的任务
分享
//给每一个input添加输入格式监听
var userName = regForm.userName;
/*userName.onkeypress=function(){
if(!/^\w{2,16}$/.test(userName.value)){
userName.warningNode.style.display="inline";
userName.noticeNode.style.display="inline";
userName.focus();
return;
}else{
userName.warningNode.style.display="none";
userName.noticeNode.style.display="none";
}
}*/
userName.onkeypress=checkFormat(!/^\w{2,16}$/.test(userName.value),userName);
}
//检测输入的格式是否正确
function checkFormat(b,tagName){
if(b){
tagName.warningNode.style.display="inline";
tagName.noticeNode.style.display="inline";
tagName.focus();
return;
}else{
tagName.warningNode.style.display="none";
tagName.noticeNode.style.display="none";
}
}