js中
<script>
function check()
{
with(document.all){
if(input1.value!=input2.value)
{
alert("false")
input1.value = "";
input2.value = "";
}
else document.forms[0].submit();
}
}
</script>
html代码:
<FORM METHOD=POST ACTION="">
<input type="password" id="input1">
<input type="password" id="input2">
<input type="button" value="test"onclick="check()">
</FORM>
<script>
function f1()
{
if(document.theform.pswc.value!=document.theform.psw.value )
{
document.theform.pswc.focus();
return false;
}
else
{
return true;
}
}
</script>
<form name="theform">
<input type="text" id="pswc" name="pswc">
<input type="text" id=psw name="psw">
<input type="button" onclick=alert(f1())>
</form>
再加一个验证两次输入密码是否相同的JavaScript代码
<script language="javascript">
function CheckForm()
if (document.form.PWD.value != document.form.PWD_Again.value) {
alert("您两次输入的密码不一样!请重新输入.");
document.ADDUser.PWD.focus();
return false;
}
return true;
}
</script>