function checkConfirmPassword(){
var password=document.getElementById('password');//第一次输入的密码
var password_info=document.getElementById('password_info');//密码输入错误提示
var confirm_password=document.getElementById('confirm_password');//确认码
var confirm_password_info=document.getElementById('confirm_password_info');//确认码错误提示 if (trim(confirm_password.value) =="") 

confirm_password.className="textfieldRequiredState";
confirm_password_info.className="errInfo";
errNum=errNum+1;

else
{
var filter=/^\s*[A-Za-z0-9]{6,16}\s*$/;
if (!filter.test(confirm_password.value)) { 
confirm_password.className="textfieldRequiredState";
confirm_password_info.className="errInfo";
errNum=errNum+1;

else
{
confirm_password.className="textfieldValidState";
confirm_password_info.className="";
}

 
if (trim(confirm_password.value) !=trim(password.value)) 

confirm_password.className="textfieldRequiredState";
confirm_password_info.className="errInfo";
errNum=errNum+1;

else
{
confirm_password.className="textfieldValidState";
confirm_password_info.className="";
}

}}

解决方案 »

  1.   

    var confirmpasswd=document.login.cpasswd.value;
    if (newpasswd != confirmpasswd) {
            mesg = mesg + "输入的密码不一致!\n";
    }
      

  2.   


    function checklogin()
    {
        mesg = ""; 
        var regname=document.login.UserName.value; 
        var newpasswd=document.login.passwd.value;
        var confirmpasswd=document.login.confirmpasswd.value;
        if( regname == null || regname == "" ) {
            mesg = mesg + "用户名不得为空!\n"; 
        }
        if( regname.length < 4 || regname.length > 16 ) {
            mesg = mesg + "用户名长度只能在4到16之间!\n"; 
        }
        if(! /^(\w)*$/.test( regname ) ) {
            mesg = mesg +"用户名只允许为英文和数字的混合,\n请检查是否前后有空格或者其他符号!\n";
        }
        if (newpasswd == null || newpasswd == "" ) {
            mesg = mesg + "密码不得为空!\n";
        }
        if( newpasswd.length < 8 || newpasswd.length > 16 ) {
             mesg = mesg + "密码长度只能在8到16之间!\n";
        }
        if( newpasswd != confirmpasswd ) {
             mesg = mesg + "两次输入的密码不一致!\n";
        }
        if (mesg != ""){
            mesg = mesg ;;//请填写好以下各项
            alert(mesg);
            return false;
        }
        login.submit();
    }
         
    function nocn(){ 
    for(i=0;i <document.getElementsByName("nocn")[0].value.length;i++){ 
    var c = document.getElementsByName("nocn")[0].value.substr(i,1); 
    var ts = escape(c); 
    if(ts.substring(0,2) == "%u"){ 
    document.getElementsByName("nocn")[0].value = ""; 
    alert("这里不能输入中文/全角字符");