Manually set unobtrusive validation error on a textbox

First, you can add a validation summary: @Html.ValidationMessageFor(m => m.Slug) Then you can manually trigger jQuery validation / unobtrusive validation with the .showError method. Here is a sample: var errorArray = {}; errorArray[“Slug”] = ‘Some error message for the Slug text box’; $(‘#SomeFormId’).validate().showErrors(errorArray);

jquery validation: prevent form submit

You may try this (Example): $(function(){ $(“#myform”).validate(); $(“#myform”).on(‘submit’, function(e) { var isvalid = $(“#myform”).valid(); if (isvalid) { e.preventDefault(); alert(getvalues(“myform”)); } }); }); function getvalues(f) { var form=$(“#”+f); var str=””; $(“input:not(‘input:submit’)”, form).each(function(i){ str+=’\n’+$(this).prop(‘name’)+’: ‘+$(this).val(); }); return str; }

JQuery Validate multiple fields with one error

Similar to Chris’s $(“form”).validate({ rules: { DayOfBirth: { required: true }, MonthOfBirth: { required: true }, YearOfBirth: { required: true } }, groups: { DateofBirth: “DayOfBirth MonthOfBirth YearOfBirth” }, errorPlacement: function(error, element) { if (element.attr(“name”) == “DayOfBirth” || element.attr(“name”) == “MonthOfBirth” || element.attr(“name”) == “YearOfBirth”) error.insertAfter(“#YearOfBirth”); else error.insertAfter(element); } });