last day (14 days later) » 

12:03 PM
0
A: what how to Valid the form when Input type is Button in MVC

Moksh Shahtry bellow code, $(".btn-next").click(function() { if ($("form").valid()) { //Some code to move on next tab } else { //Do something if form is InValid // Error messages will be auto populated, in case if you want some more furniture, use this block :) } }); ...

 
Let me check it. I need something like this only.
Actually this is validating the form but it's not showing any error message. I have done data annotation validation with this form. Is there any way those error message will display when validation failed ?
 
Yes this way it will populate error message too, just check that fiddle
I'm assuming client side validation is enabled in your page.
 
I have checked it but error is not displaying. It is only preventing the page to submit.
 
Have you checked fiddle ? can you post your code,on how you enabled client side validation ?
 
Yes it's enable already.
i have used <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> in web.config file
 
12:04 PM
Do you have multiple forms in your page?
if you have multiple forms then use specific form ID $("#SPECIFICFORMID").valid()
 
No i am using only one form
i am using @Html.EditorForModel() to display Employee wizard in my page
 
12:35 PM
Can you post your complete HTML herE?
 
This my EditorForModel of Employee
<div class="wizard-container">
<div class="card wizard-card ct-wizard-green" id="wizard">
<!-- You can switch "ct-wizard-azzure" with one of the next bright colors: "ct-wizard-blue", "ct-wizard-green", "ct-wizard-orange", "ct-wizard-red" -->
<div class="wizard-header">
<h3>
<b>LIST</b> THE EMPLOYEES <br>
<small>This information will let us know about the new employee.</small>
</h3>
</div>
<ul>
<li><a href="#personal" data-toggle="tab">Personal Details</a></li>
<li><a href="#address" data-toggle="tab">Address</a></li>
This my Employee Entry Wizard
@using (Html.BeginForm("Create", "Employees", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<!-- Wizard container -->
@Html.EditorForModel()
<!-- wizard container -->
}
 

last day (14 days later) »