使用jquery删除元素上的验证器

时间:2014-06-04 12:14:14

标签: javascript jquery

我有以下html向下钻取控件,它是在运行时生成的。我想要禁用它上面的所有验证。

 <label class="mark" for="SupportTo_L1" id="SupportTo_L1_Label">select a value&nbsp;</label>

 <select aria-labelledby="SupportTo_L1_Label SupportTo_L1_Error" aria-required="true" 
         class="op-combobox" data-ishorizontal="true" data-drilldowntype="true"
         data-register-change-event="true" data-val="true"
         data-val-required="<img class='validateicon'              
         src='https://sxsvc.supp.maro.com/PAdvy0.0.0/Content/Images/16x16-red-alert.png'/><font color='Red'>*</font> Required"
         id="SupportTo_L1"
         name="SupportTo_L1" title="Technology group involved in the project:">

<button class="submitbutton" id="submit" name="submit" type="submit" 
        value="submit">Submit</button>

但是当我点击提交按钮时,它仍然会在此向下钻取验证。我尝试了下面的代码,但是没有用。我还需要禁用其他内容。

$('#SupportTo_L1').attr(
     {'data-val':'false','aria-required':'false'}
    );

3 个答案:

答案 0 :(得分:1)

我这样做了,

document.getElementById("elemenId").required = false;

答案 1 :(得分:0)

我会试试这个:

$('#SupportTo_L1').removeAttr('data-val');
$('#SupportTo_L1').removeAttr('aria-required');

答案 2 :(得分:0)

$("#submit").click (function (e) {
e.preventDefault();
$("select.op-combobox").attr("data-val","false");
$("select.op-combobox").attr("aria-required","false");
});