参考
_cshtml_
<form id="myform">
<input type="text" id="myinput" name="myinput" />
<a href="javvascript:vlid()" onclick="check()">check!!</a>
</form>
@section scripts{
@Scripts.Render("~/bundles/jqueryval")
<script type="text/javascript">
$(function() {
$('#myform').validate({
rules: {
myinput: {
required: true,
}
},
messages: {
myinput:"必須項目です。",
},
errorPlacement: function (error, element) {
element.after(error).after('<br/>');
}
});
});
function check() {
alert("result:" + $('#myform').valid());
}
</script>
}