【发布时间】:2013-05-17 11:50:49
【问题描述】:
我想验证一个具有输入为type="radio" 的控制组的表单,如下所示:
<form id="sendMessageFormContainer" action="#">
@Html.ValidationSummary()
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>To:</legend>
<div id="messageToContainer">
<input type="radio" name="radio-choice-1" id="radio-choice-1" value="1" />
<label for="radio-choice-1">foo</label>
<input type="radio" name="radio-choice-1" id="radio-choice-2" value="2" />
<label for="radio-choice-2">bar</label>
</div>
</fieldset>
</div>
//...
<input id="sendMsgBtn" name="sendMsgBtnName" type="submit" value="Send" />
</form>
我正在使用validate() 方法来验证其余元素,但我不知道应该使用哪个规则来检查是否应至少选择一个单选按钮:
$(document).on("pageshow", function () {
$("#sendMessageFormContainer").validate({
rules: {
//???
},
messages: {
//...
},
submitHandler: function (form) {
alert("Call Send Action");
}
});
});
【问题讨论】:
标签: html jquery-mobile jquery-validate jquery-mobile-fieldset jquery-mobile-radio