In our application we have multiple instances of the same form in different tabs (one tab for each client). We use the MVC2 jquery validation to validate these forms, using the Html.textboxFor and Html.ValidationMessageFor elements.
The problem exibits itself when we have two tabs. When we give wrong input in the second form (second tab), the validationmessage is shown on the (closed) first tab. It seems that the validation message is linked to the ID of the validationmessage (and thus
only linked to the first form), and not to the combination of the form with the ID.
How should we approach this problem, any thoughts?
Two forms with same TextBox ID's will also create some problem when you post Text Box Data because you have no way to know that whther it is tab 1 TextBox or tab 2.
Easy approach is to create two Model and Post these data in different actions
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
VinZ40K
0 Points
1 Post
MVC2 jQuery Validation with jQuery UI Tabs
May 12, 2010 03:06 PM|LINK
In our application we have multiple instances of the same form in different tabs (one tab for each client). We use the MVC2 jquery validation to validate these forms, using the Html.textboxFor and Html.ValidationMessageFor elements.
The problem exibits itself when we have two tabs. When we give wrong input in the second form (second tab), the validationmessage is shown on the (closed) first tab. It seems that the validation message is linked to the ID of the validationmessage (and thus only linked to the first form), and not to the combination of the form with the ID.
How should we approach this problem, any thoughts?
Example:
<% Html.EnableClientValidation(); %> <div id="tab1"> <% Html.BeginForm(); %> <%= Html.LabelFor(m => m.User) %> <%= Html.TextBoxFor(m => m.User)%> <%= Html.ValidationMessageFor(m => m.User) %> <% Html.EndForm(); %> </div> <div> <% Html.BeginForm(); %> <%= Html.LabelFor(m => m.User) %> <%= Html.TextBoxFor(m => m.User)%> <%= Html.ValidationMessageFor(m => m.User) %> <% Html.EndForm(); %> </div>imran_ku07
All-Star
45785 Points
7698 Posts
MVP
Re: MVC2 jQuery Validation with jQuery UI Tabs
May 12, 2010 05:34 PM|LINK
Two forms with same TextBox ID's will also create some problem when you post Text Box Data because you have no way to know that whther it is tab 1 TextBox or tab 2.
Easy approach is to create two Model and Post these data in different actions
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD