jQuery error in ASP.NET MVC 3 clientside custom validation
I have a razor view in ASP.NET MVC3 application.
This view has 2 partialviews
- PartialView1 is strongly typed and binded with the model.
- PartialView2 is not binded with the model. and this view consists of a collection of checkboxes.
As part of validation atleast one checkbox must be checked to continue with the save.
Following is the jquery code that is giving me error: Object does not support this property or method.
Error occuring at this line of code: $("#form0").validate({ rules: { issueCheckBox: { selectNone: true}} });
Following is the JQuery code:
<script src="../../Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script>
$.validator.addMethod
(
"selectNone",
function (value, element) {
var n = $("input[name='issueCheckBox']:checked").serializeArray();
if (n.length < 1) {
$("#divIssueCheckBoxError").show();
$("#divIssueCheckBoxE开发者_开发百科rror").css("color", "red");
$("#divIssueCheckBoxError").text("Issue(s) Required. Please select atleast one issue.");
return false;
}
else {
$("#divIssueCheckBoxError").hide();
return true;
}
},
function () { }
);
jQuery(document).ready(function () {
$("#form0").validate({ rules: { issueCheckBox: { selectNone: true}} });
});
</script>
Does this error only happen in IE9? If so, it may just be this jquery ie9 bug related getElementsByTagName.
精彩评论