After trying to avoid JavaScript for years, Iv started using JQuery for validation in MVC asp.net, as there does not seem to be an official way of doing validation, Iv been surprised how good JQuery is.
Firstly is there a way to get intellisense working for JQuery and its validation plugin, so that i don have to learn the api?
Secondly how do I create a validation summary for this, it currently appends the error to the right of the text box.:
<script type="text/javascript">
$().ready(function() {
$("#CreateLog").validate({
rules: {
UserName: {
required: true,
minLength: 2,
}
},
messages: {
UserName: {
required: "Please enter a username",
minLength: "Your username must consist of at least 2 characters",
}
}
});
});
</script>
<form id="CreateLog" action="Create" method="post" />
<label>UserName</label><br />
<%=Html.TextBox("UserName")%>
<br />
<div class="error"> </div>
<input type=submit value=Save />
</form>
I tried adding this to the script:
errorLabelContainer: $("#CreateLog div.error")
and this to the html:
<div class="error"> </div>
But this didn't work.