在Jquery验证中从select字段中禁用验证[' required']

时间:2014-11-26 17:08:22

标签: jquery validation

我一直在我的网页上使用jquery validate插件。所以这是我的情景:

我有两个按钮Button1和Button2,当我点击Button1时,应该启用选择字段/下拉列表的验证,当我点击Button2时,应该禁用验证。

尝试以下方法但未取得任何成功:

$("#"+elementId).attr("validation", "");

$("#"+elementId).removeAttr("validation");

$("#"+elementId).removeClass("required");

$("#"+elementId).removeClass("validation");

需要删除以下HTML的验证

<div class='question ' id='questionDiv_16881'><div class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-corner-all ui-li-has-count ui-btn-up-c"><div class="questionText">2.11 Multi-Part - Conditional - Drop Down</div></div><div class="mainQuestion"><div data-role="fieldcontain"> <fieldset data-role="controlgroup" data-type="horizontal"> <legend>Multi-Part - Conditional - Drop Down</legend> <input type="radio" class="required checklistQuestionField" name="Question_16881" id="Question_16881_DropDown" value="Drop Down"/> <label for="Question_16881_DropDown">Drop Down</label><input type="radio" class="required checklistQuestionField" name="Question_16881" id="Question_16881_NoDropDown" value="No Drop Down"/> <label for="Question_16881_NoDropDown">No Drop Down</label> <img class="questionImage" src="" data-role="questionReferenceImage" id="Question_16881_ReferenceImage"/> </fieldset></div></div><div class='questionParts' id='questionPartsDiv_16881'></div></div>

当用户点击&#34; DropDown&#34;时,会出现选择字段按钮

<label for="QuestionPart_717496" generated="true" class="" style="display: block;">This field is required.</label><legend>Drop Down<span style="vertical-align: top;color:red;margin-left:5px;"></span></legend><div class="ui-select"><div data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-icon="arrow-d" data-iconpos="right" data-theme="d" class="ui-btn ui-btn-up-d ui-shadow ui-btn-corner-all ui-btn-icon-right"><span class="ui-btn-inner"><span class="ui-btn-text"><span class="checklistQuestionField">Select...</span></span><span class="ui-icon ui-icon-arrow-d ui-icon-shadow">&nbsp;</span></span><select id="QuestionPart_717496" class="checklistQuestionField dropdownValid" validation="required" name="QuestionPart_717496"> <option>Select...</option> <option value="List Item 1">List Item 1</option><option value="List Item 2">List Item 2</option><option value="List Item 3">List Item 3</option><option value="List Item 4">List Item 4</option><option value="List Item 5">List Item 5</option> </select></div></div>

0 个答案:

没有答案