function comparePwd()
{
var pwd1=document.forms[0].userAccountsPwd.value; userAccountsPwd为控件property
var pwd2=document.forms[0].userAccountsPwdOK.value;
if(pwd2!=pwd1)
{
alert("两次输入的密码不一致");
document.forms[0].userAccountsPwd.value="";
document.forms[0].userAccountsPwdOK.value="";
document.forms[0].userAccountsPwd.focus();
}
}
最后在确认密码框的失去焦点去调用就好了οnblur="comparePwd();"
{
var pwd1=document.forms[0].userAccountsPwd.value; userAccountsPwd为控件property
var pwd2=document.forms[0].userAccountsPwdOK.value;
if(pwd2!=pwd1)
{
alert("两次输入的密码不一致");
document.forms[0].userAccountsPwd.value="";
document.forms[0].userAccountsPwdOK.value="";
document.forms[0].userAccountsPwd.focus();
}
}
最后在确认密码框的失去焦点去调用就好了οnblur="comparePwd();"