Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
动态添加/删除jQuery验证引擎类_Jquery_Asp.net_Jquery Validation Engine - Fatal编程技术网

动态添加/删除jQuery验证引擎类

动态添加/删除jQuery验证引擎类,jquery,asp.net,jquery-validation-engine,Jquery,Asp.net,Jquery Validation Engine,我正在使用jQuery验证引擎插件来验证我的表单。根据条件,如果失败,我必须删除一个控件的验证,如果成功,我必须分配验证,反之亦然 //代码: Html: 来源于浏览器: 分配前: <select name="ctl00$ContentPlaceHolder1$ddlCourierId" id="ContentPlaceHolder1_ddlCourierId"> <option value="0">Select</option> <

我正在使用jQuery验证引擎插件来验证我的表单。根据条件,如果失败,我必须删除一个控件的验证,如果成功,我必须分配验证,反之亦然

//代码:

Html:


来源于浏览器:

分配前:

<select name="ctl00$ContentPlaceHolder1$ddlCourierId" id="ContentPlaceHolder1_ddlCourierId">
    <option value="0">Select</option>
    <option value="1">Professional</option>
    <option value="2">STCourier</option>

</select>

挑选
专业的
信使
分配后:

<select name="ctl00$ContentPlaceHolder1$ddlCourierId" id="ContentPlaceHolder1_ddlCourierId" class="validate[required]">
    <option value="0">Select</option>
    <option value="1">Professional</option>
    <option value="2">STCourier</option>

</select>

挑选
专业的
信使
脚本:

function disableCourier() {

            var e = document.getElementById('<%= ddlTransporterType.ClientID%>');
            var f = document.getElementById('<%= ddlCourierId.ClientID%>');
            var strUser = e.options[e.selectedIndex].value;
         //   alert(strUser);
            if (strUser == 1 || strUser == 2){
                f.disabled = true;
                $('#<%= ddlCourierId.ClientID%>').removeClass("validate[required]");
                }
            else {
                f.disabled = false;
                $('#<%= ddlCourierId.ClientID%>').addClass("validate[required]");
            }
        }
函数disableCourier(){
var e=document.getElementById(“”);
var f=document.getElementById(“”);
var strUser=e.options[e.selectedIndex].value;
//警报(strUser);
如果(strUser==1 | | strUser==2){
f、 禁用=真;
$('#').removeClass(“验证[必需]”);
}
否则{
f、 禁用=错误;
$('#').addClass(“验证[必需]”);
}
}
上面的代码不起作用,这意味着没有错误,当我使用inspect元素检查时,类被分配,但在浏览器中验证不起作用


有什么帮助/想法吗?

和是完全不同的两件事。编辑。另外,请显示呈现的HTML代码。。。毕竟,这个问题是关于客户端代码的。这些是我验证的HTML代码。这不是呈现的HTML。“呈现”HTML是您在浏览器中看到的内容,而不是您上传到服务器的内容。@Sparky:更新了我的问题。请调查一下。
function disableCourier() {

            var e = document.getElementById('<%= ddlTransporterType.ClientID%>');
            var f = document.getElementById('<%= ddlCourierId.ClientID%>');
            var strUser = e.options[e.selectedIndex].value;
         //   alert(strUser);
            if (strUser == 1 || strUser == 2){
                f.disabled = true;
                $('#<%= ddlCourierId.ClientID%>').removeClass("validate[required]");
                }
            else {
                f.disabled = false;
                $('#<%= ddlCourierId.ClientID%>').addClass("validate[required]");
            }
        }