我正在验证调查问题,它包含无线电类型问题和复选框类型问题...无线电类型问题工作正常,复选框无效...在名称字段中我传递question_id作为单选按钮和question_id的名称+ option_id作为复选框的名称...
如果我只为复选框输入问题ID,则验证但我需要检查多个选项......
//收音机
<input type="radio" class=" radio" name="31" value="101" style="width: auto;display: inline-block;height: auto;"> Good
<input type="radio" class=" radio" name="31" value="102" style="width: auto;display: inline-block;height: auto;"> Average
//复选框
<input type="checkbox" class="required check" id="20" name="20_85" style="width: auto;display: inline-block;height: auto;" value="85"> Not good
<input type="checkbox" class="required check" id="20" name="20_84" style="width: auto;display: inline-block;height: auto;" value="84"> Good
我需要验证此复选框。
//点击时进行jquery验证。
<script type="text/javascript">
$(function() {
$(window).off("resize");
$(window).on("resize", function() {
var newHeight = $("body").outerHeight() + 20;
if($("html").outerHeight() > newHeight) {
newHeight = $("html").outerHeight();
}
parent.postMessage(newHeight, '*');
}).trigger("resize");
var validationParameters = {
rules: {
mobileNumber1: {
required: true,
digits: true,
rangelength: [10,10]
}
},
errorPlacement: function(error, element) {
if($(element).prevAll("label:first").length > 0) {
$(element).prevAll("label:first").after(error);
}
else {
$(element).parent().prevAll("label:first").after(error);
}
$(window).trigger("resize");
},
success: function(label) {
$(window).trigger("resize");
}
};
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1;
if(isAndroid) {
validationParameters.onkeyup = function(element, event) { };
validationParameters.focusInvalid = function(element, event) { };
validationParameters.onfocusout = function(element, event) { };
}
$("#customerMakeReservation2Mobile").validate(validationParameters);
$("#continueButton").click(function() {
if($("#customerMakeReservation2Mobile").valid()) {
var phone = $("#mobileNumber1").val();
$("#phone1").val(phone.substr(0, 3));
$("#phone2").val(phone.substr(3, 3));
$("#phone3").val(phone.substr(6, 4));
$("#customerMakeReservation2Mobile").submit();
}
});
});
</script>