<input id="id1" type="text" /><br />
<input id="id2" type="password" /><br />
<input id="id3" type="password" /><br />
<input id="Button1" type="button" value="提交" onclick="but_click();" />
当点击提交按钮的时候多id1,id2,id3 进行验证.1,输入不能为空;2必须正确输入;
<input id="id2" type="password" /><br />
<input id="id3" type="password" /><br />
<input id="Button1" type="button" value="提交" onclick="but_click();" />
当点击提交按钮的时候多id1,id2,id3 进行验证.1,输入不能为空;2必须正确输入;
<script>
function but_click(){
var f = document.forms[0];
var t1 = document.getElementById("id1").value;
var t2 = document.getElementById("id2").value;
var t3 = document.getElementById("id3").value;
t1 = t1.replace(/(^\s+|\s+$)/g,"");
t2 = t2.replace(/(^\s+|\s+$)/g,"");
t3 = t3.replace(/(^\s+|\s+$)/g,"");
if(t1=="" || t2=="" || t3==""){
alert("不能为空");
return false;
}
if(t2!=t3){
alert("密码不相等");
return false;
}
f.submit()
}
</script>
<form action="xxx" method="post">
<input id="id1" type="text" /> <br />
<input id="id2" type="password" /> <br />
<input id="id3" type="password" /> <br />
<input id="Button1" type="button" value="提交" onclick="but_click();" />
</form>
var id1=document.getElementById("id1");
var id2=document.getElementById("id2");
var id3=document.getElementById("id3");
if(id1.innerText&&id2.innerText&&id3.innerText){
alert("null")
return false;
}
if(id1.innerText!="xxxxx"&&id2.innerText!="xxxx"&&id3.innerText!="xxx") return false
return true
<input id="id2" type="password" onblur="but_click()" /> <br />
<input id="id3" type="password" onblur="but_click()" /> <br />
<script>
function b1(){
var t1 = document.getElementById("id1").value;
t1 = t1.replace(/(^\s+|\s+$)/g,"");
if(t1==""){
alert("不能为空");
return false;
}
else return true;
}
function b2(){
var t2 = document.getElementById("id2").value;
t2 = t2.replace(/(^\s+|\s+$)/g,"");
if(t2==""){
alert("密码1不能为空");
return false;
}
return true;
}
function b3(){
var t3 = document.getElementById("id3").value;
t3 = t3.replace(/(^\s+|\s+$)/g,"");
if(t3==""){
alert("密码2不能为空");
return false;
}
return true;
}function but_click(){
var f = document.forms[0];
var t2 = document.getElementById("id2").value;
var t3 = document.getElementById("id3").value;
b = b1() & b2() & b3();
if(!b) return false;
if(t2!=t3){
alert("密码不相等");
return false;
}
f.submit()
}
</script>
<form action="xxx" method="post">
<input id="id1" type="text" onblur="b1()"/> <br />
<input id="id2" type="password" onblur="b2()"/> <br />
<input id="id3" type="password" onblur="b3()"/> <br />
<input id="Button1" type="button" value="提交" onclick="but_click();" />
</form>