Last post Aug 22, 2013 05:24 PM by Mikesdotnetting
Aug 22, 2013 02:12 PM|TmoodASP|LINK
Once again, previous forum's solution does not appear to apply to Razor Syntax as it's slightly different.
I have multiple forms on one page and if a user submit an empty field, the validation summary display ALL the error including the forms that have not yet been submitted.
How can I get the Validation to differentiate between forms that's being submitted??
Many thanks in advance!
Validation.RequiredField("firstname","Must have first name");
Validation.RequiredField("lastname", "Must have last name");
Validation.RequiredField("email", "Must have email");
Validation.RequiredField("phonenumber", "Must have phone number");
This is not my actual code but for clarity's sake: first and last name input is the first form, it has to be submitted before moving on to second form that ask for email and phone number.
If a user left first and last name field empty, the Validation call the error for first and last name AND email and phone number. I want Validation to display error only on first and last name since that was submitted, not email and phone number.
Aug 22, 2013 03:17 PM|CriticalError|LINK
This should help you: http://blog.thecodingguys.net/article/36/2013/august/asp-net-webpages-multiple-submit-buttons
You'd have to put validation in the if statements for the button submited:
//Code for AddRole.
I have not tried it but it should work.
Aug 22, 2013 05:24 PM|Mikesdotnetting|LINK
You can't very easily use the new Validation helpers for this. You need to manually populate the ModelState dictionary with the individual form errors relevant to the form being submitted.