0

这是用于验证注册表单的 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()函数没有被调用。你能弄清楚什么是错的吗?

4

1 回答 1

0

像这样的东西:

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()
}
于 2013-07-12T14:03:17.043 回答