I have tested jquery validate with Ajax.BeginForm from asp.net mvc and although the form validate, the error message is not displayed if the form is not valid.
FORM CODE:
@using (Ajax.BeginForm("Save", "Student", null,
new AjaxOptions { HttpMethod = "POST", OnSuccess = "StudentSucess", OnFailure = "StudentFail", OnBegin = "validateForm", },
new { id = "form-student" }))
{
<div class="form-group">
<input type="hidden" class="form-control" id="Id" name="Id" />
</div>
<div class="form-group">
<label>TESTE</label>
<select name="Test" required="" class="form-control">
<option value="">Select</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select>
</div>
<div class="form-group">
<input type="text" class="form-control" id="Name" name="Name" placeholder="Name" autocomplete="off" required="" />
</div>
<div class="form-group m-t-10">
<button type="submit" class="btn btn-theme">Create</button>
</div>
}
VALIDATE FUNCTION CODE
function validateForm() {
var valid = $("#form-student").validate({
rules: {
Name: {
required: true
},
Test: {
required: true
},
},
messages: {
Name: {
required: "Your name is required"
},
Test: {
required: "Test is required"
},
}
});
return valid;
}
I need the message of the respective validated field to be displayed.
IMPORTANT: A stackoverflow user tagged that same question as a duplicate, and the question was different from the one he said was duplicated, does not solve that problem. I tried all the solutions of the comments, but they did not work for me.

$("#form-student").validate({....})outside the validateForm() method