JAvawebは登録インタフェースを実現し、リアルタイムで検証する
5076 ワード
前回書いたリロードシステムがなくなったので今回はバックアップしましょう
Insert title here
function checkuser(){
var ch=true;
var red=document.getElementById("1");
var t1=document.getElementById("user").value;
if(t1.length<3||t1.length>5)
{
red.style.color="red";
ch=false;
}
else
red.style.color="green";
return ch ;
}
function checkpass(){
var ch =true;
var red2=document.getElementById("2");
var t2=document.getElementById("pass").value;
if(t2.length<8||t2.length>12)
{
red2.style.color="red";
ch=false;
}
else
red2.style.color="green";
return ch;
}
function checkpass1(){
var ch=true;
var red3=document.getElementById("3");
var t3=document.getElementById("pass1").value;
var t2=document.getElementById("pass").value;
if(t2!=t3)
{
red3.style.color="red";
ch=false;
}
else
red3.style.color="green"
return ch;
}
function checkemail(){
var ch =true;
var red4=document.getElementById("4");
var t4=document.getElementById("em").value;
var a =t4.indexOf("@");
var b= t4.indexOf(".");
if(a==-1||b==-1||b<a)
{
red4.style.color="red"
ch=false;
}
else
red4.style.color="green"
return ch;
}
function checkpnumber(){
var ch=true;
var red5=document.getElementById("5");
var t5=document.getElementById("pnumber").value;
if(t5.length==11)
red5.style.color="green";
else
{
red5.style.color="red";
ch=false;
}
return ch;
}
function checksheng(){
var check;
var red=document.getElementById("7");
if(document.getElementById("shengfen").selectedIndex == 0)
{
red.style.color="red";
check = false;
}else{
red.style.color="green";
check = true;
}
return check;
}
function checkrname(){
var ch=true;
var a =document.getElementById("rname").value;
var red=document.getElementById("6");
if(a.length<2||a.length>5){
red.style.color="red";
ch=false;
}
else
red.style.color="green";
return ch;
}
function checkoption(){
var ch=false;
var len =document.getElementByName("hobby").length;
for( i=0;i<len;i++){
if(document.getElementsByName('hobby')[i].checked){
ch=true;
}
}
if(ch!=true){
alert(" ");
}
return ch;
}
function check(){
if(checkuser()&&checkpass()&&checkpass1()&&checkemail&&checkpnumber()&&checksheng()&&checkrname()&&checkoption())
return true ;
else
return false;
}
```