JS实现用户注册界面功能
var sub=document.getElementById(“sub”);
var txt=document.getElementsByClassName(“txt”);
var li=document.getElementsByTagName(“li”);
document.forms.form.onsubmit=function(){
yan();
var errl=document.getElementsByClassName(“error”).length;
if(!errl){
return true;
}
return false;
};
function yan(){
for(var i=0;i<txt.length;i++){
txt[i].focus();
}
sub.focus();
}
for(var i=0;i<txt.length;i++)
{
txt[i].index=i;
txt[i].onfocus=function (){
if(this.parentElement.children[2]==undefined) return;
this.parentElement.children[2].remove();
};
txt[i].onblur=function (){
switch (this.index){
case 0:
if(this.value==””){
var s=document.createElement(“span”);
s.innerHTML=”请输入账号”;
s.className=”error”;
li[this.index].appendChild(s)
}
else{
var s=document.createElement(“span”);
s.innerHTML=””;
s.className=”sucess”;
li[this.index].appendChild(s)
}
break;
case 1:
if(this.value==””){
var s=document.createElement(“span”);
s.innerHTML=”请输入密码”;
s.className=”error”;
li[this.index].appendChild(s)
}
else if(this.value.length<6||this.value.length>11) {
var s=document.createElement(“span”);
s.innerHTML=”密码错误”;
s.className=”error”;
li[this.index].appendChild(s);
txt[this.index].value=””;
}
else{
var s=document.createElement(“span”);
s.innerHTML=””;
s.className=”sucess”;
li[this.index].appendChild(s)
}
break;
case 2:
if(this.value==””){
var s=document.createElement(“span”);
s.innerHTML=”请再次确认密码”;
s.className=”error”;
li[this.index].appendChild(s);
txt[this.index].value=””;
}
else if(this.value!=txt[1].value){
var s=document.createElement(“span”);
s.innerHTML=”请重新输入”;
s.className=”error”;
li[this.index].appendChild(s);
txt[this.index].value=””;
}
else{
var s=document.createElement(“span”);
s.innerHTML=””;
s.className=”sucess”;
li[this.index].appendChild(s)
}
break;
case 3:
if(this.value==””){
var s=document.createElement(“span”);
s.innerHTML=”请输入号码”;
s.className=”error”;
li[this.index].appendChild(s)
}
else if(this.value.length!=11){
var s=document.createElement(“span”);
s.innerHTML=”号码格式错误”;
s.className=”error”;
li[this.index].appendChild(s)
txt[this.index].value=””;
}
else{
var s=document.createElement(“span”);
s.innerHTML=””;
s.className=”sucess”;
li[this.index].appendChild(s)
}
break;
case 4:
if(this.value==””){
var s=document.createElement(“span”);
s.innerHTML=”请输入邮箱”;
s.className=”error”;
li[this.index].appendChild(s)
}
else{
var s=document.createElement(“span”);
s.innerHTML=””;
s.className=”sucess”;
li[this.index].appendChild(s)
}
break;
}
}
}
2024最新激活全家桶教程,稳定运行到2099年,请移步至置顶文章:https://sigusoft.com/99576.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。 文章由激活谷谷主-小谷整理,转载请注明出处:https://sigusoft.com/94587.html