Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Quote:
Hi,

I have two forms in my view page. Both forms have few textboxes and submit button. All the textboxes have required field validation. My problem is ,on submit of first form, the second form texboxes are also getting validated. How can i solve this?



HTML
@using (Html.BeginForm("ResetUserNameAction", "User", FormMethod.Post, new { @id = "myform1" }))
 {
    @Html.AntiForgeryToken()
        <div id="usernamereset" class="row">
           
                    @Html.LabelFor(m => m.Email)
                    @Html.TextBoxFor(m => m.Email)
                    @Html.ValidationMessageFor(m => m.Email)
         <input type="submit" id="resetUserName" name="resetUserName"  class="userForm-button" value="Reset UserName"  />           
        </div>

        <br />
        <br />

 }
@using (Html.BeginForm("ResetPasswordAction", "User", FormMethod.Post, new { @id = "myform2" }))
{
    @Html.AntiForgeryToken()
        <div id="passwordreset" class="row">
           
                @Html.LabelFor(m => m.UserName)
                @Html.TextBoxFor(m => m.UserName)
                @Html.ValidationMessageFor(m => m.UserName)
            
                @Html.LabelFor(m => m.Email)
                @Html.TextBoxFor(m => m.EmailPassword)
                @Html.ValidationMessageFor(m => m.EmailPassword)
           
         <input type="submit" id="resetPasswordSendMail" class="userForm-button" value="Send Email" />
        </div>
}




Please provide a solution.
Thanks.
Posted
Updated 2-Nov-15 19:37pm
v2

comment or remove this line of code @Html.ValidationMessageFor(m => m.UserName) and this line of code @Html.ValidationMessageFor(m => m.EmailPassword)
 
Share this answer
 
comment or remove this line of code "@Html.ValidationMessageFor(m => m.UserName)" and this line of code "@Html.ValidationMessageFor(m => m.EmailPassword)"


try this step. it might help :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900