【问题标题】:Validation of password and repassword with jquery使用 jquery 验证密码和重新密码
【发布时间】:2013-07-11 01:58:51
【问题描述】:

这是用于验证注册表单的 switch 语句的最后一部分:

    case "contraseña":
    {
        if($(this).val().length < 9){
            $(".texto_req_reg").html("Debe tener más de 8 caracteres");
            $(".texto_req_reg").css("color", "#C60");
            contraseñaValida = false;
        }else{
            $(".texto_req_reg").html("Correcto");
            $(".texto_req_reg").css("color", "#990");
            contraseñaValida = true;
        }
    break;
    }
    case "repetirContraseña":
    {
        if($(this).val() === $("#contraseña").val()){
            $(".texto_req_reg").html("Correcto");
            $(".texto_req_reg").css("color", "#990");
            repContraseñaValida = true;
        }else{
            $(".texto_req_reg").html("Debe coincidir con su contraseña");
            $(".texto_req_reg").css("color", "#C60");
            repContraseñaValida = false;
        }
    break;
    }
    if($("#checkbox_legales").is(":checked")){
        checkbox_legalesValido = true;
    }else{
        checkbox_legalesValido = false;
    }
    habilitarBoton()
}
}

"repetirContraseña" case 出了点问题,因为萤火虫不允许我在该部分设置停止点,最后一个 if 和 habilitarBoton() 函数没有被调用。你能找出问题所在吗?

【问题讨论】:

  • 从未见过有人使用类似“ñ” ID ...
  • 什么是有时是错误的=?它没有进入这个“案例”或这个“案例”有什么问题吗?不明白sry..
  • 不是某个时候。这个案例有效,因为如果我写了我在 contraseña 案例中写的通行证,它会显示“Correcto”,但最后一个 if 和 hablitarBoton() 没有被读取。
  • 啊,对不起……也许break;在那里可能不好……

标签: javascript jquery forms passwords


【解决方案1】:

类似这样的事情:

case "repetirContraseña":
    {
        if($(this).val() === $("#contraseña").val()){
            $(".texto_req_reg").html("Correcto");
            $(".texto_req_reg").css("color", "#990");
            repContraseñaValida = true;
        }else{
            $(".texto_req_reg").html("Debe coincidir con su contraseña");
            $(".texto_req_reg").css("color", "#C60");
            repContraseñaValida = false;
        }
    if($("#checkbox_legales").is(":checked")){
        checkbox_legalesValido = true;
    }else{
        checkbox_legalesValido = false;
    }
    habilitarBoton()
    break;
    }

或

case "repetirContraseña":
    {
        if($(this).val() === $("#contraseña").val()){
            $(".texto_req_reg").html("Correcto");
           $(".texto_req_reg").css("color", "#990");
            repContraseñaValida = true;
        }else{
            $(".texto_req_reg").html("Debe coincidir con su contraseña");
            $(".texto_req_reg").css("color", "#C60");
            repContraseñaValida = false;
        }
    }
default : {
  if($("#checkbox_legales").is(":checked")){
        checkbox_legalesValido = true;
    }else{
        checkbox_legalesValido = false;
    }
    habilitarBoton()
}

【讨论】:

    猜你喜欢
    • 2018-05-07
    • 1970-01-01
    • 1970-01-01
    • 2020-08-16
    • 1970-01-01
    • 2018-11-27
    • 2013-09-18
    • 1970-01-01
    • 2015-09-23
    相关资源
    最近更新 更多