0
有一個隱藏/可見的基於無線電的字段。以前隱藏的字段的jquery驗證器
因此而載入網頁,我們使其可見基於無線電值
$(document).ready(function() {
if(edit) {
populateData();
}
$(radio).change(function(){
//here also we show hide text box based on radio value
})
function PopulateData() {
//This does select radio and based on same show/hide text field
}
$("myForm").validate(); // attaching validate . At this point field could be hidden or visible
$(savebutton).click(function(){
/*This does not validate text
field (visibleBasedOnRadio) which was hidden and made visible by either of above */
if($("myForm").valid() == false) {
return false;
}
});
});
<form id="myForm">
<radio>
<option 1>
<option 2>
</radio>
<input type="text" id="visibleBasedOnRadio" class="required" style="display:none"/>
</form>