Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7874123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:43:28+00:00 2026-06-03T02:43:28+00:00

So I have a multi-step process that allows a user to retrieve a forgotten

  • 0

So I have a multi-step process that allows a user to retrieve a forgotten password. The steps are like so, with a different action for each step in my controller:

  1. Enter username and email
  2. Enter password question answer
  3. Email a recovery link to the user if all goes well

I tried using one model for everything:

public class AccountForgotPassword
{

    [Required()]
    [DisplayName("Username")]
    public string UserName { get; set; }

    [Required()]
    public string Email { get; set; }

    [Required()]
    public string PasswordAnswer { get; set; }

}

But when I check ModelState.IsValid on the first action, since the user can’t input their password answer question yet, it will always be false and makes for some interesting code to check that the model state is in fact valid but is only missing the password answer since I don’t know who the user is yet.

To get around this, I decided to forgo a typed model and just use string parameters in my actions. Only problem now is that I can no longer use the easy validation wire-ups you get with model binding.

With that said, does anyone know an easy way to manually wire-up the jQuery validation to individual inputs so it will check the required rule? Also, will this wiring allow me to use the default error messages the validator generates, or will I have to supply my own upon wiring them up? Would it be this easy in my view:

@{
    ViewBag.Title = "Forgot Password";
}
<h2>
    Forgot Password</h2>
@using (Html.BeginForm())
{ 
    <p>
        @Html.Label("UserName", "Username")
        @Html.TextBox("UserName")
        @Html.ValidationMessage("UserName")
    </p>

    <p>
        @Html.Label("Email", "Email")
        @Html.TextBox("Email")
        @Html.ValidationMessage("Email")
    </p>

    <p>
        <input type="submit" value="Send Form" />
    </p>
}

<script type="text/javascript">
    $.validator.unobtrusive.addRule(..something here...);
</script>

Also if there is a better way to do this, please let me know.

UPDATE

For anyone else that finds this, I did figure out how to add the rules manually. Should have just read the validation docs first. Assuming the view html above, the script would be:

<script type="text/javascript">
    $(function () {
        $('#UserName').rules('add', {
            required: true,
            messages: {
                required: 'The username field is required.'
            }
        });

        $('#Email').rules('add', {
            required: true,
            messages: {
                required: 'The email field is required.'
            }
        });

        $.validator.unobtrusive.parse('form');
    });
</script>

However, after thinking about it some more and taking AFinkelstein’s answer into account, I think I will just go ahead and make 2 different view models and let the framework do the work for me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:43:31+00:00Added an answer on June 3, 2026 at 2:43 am

    If you validate just the username and password first, and then the Password answer second, I think the easiest solution is to have two separate View Models. Then you can still use the appropriate View Model and validation for each section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-step BackgroundWorker process. I use a marquee progress bar because several
I have a longer running multi-step process using BackgroundWorker and C#. I need to
I have a multi-step form and user can navigate to any page to modify
I have a Cocoa app with a custom, multi-step account setup that I implemented
I have a multi-step file import process. I have a hidden form input in
I have a large multi-step form that will insert a record into a database.
I have a multistep process where each step does some network IO (web service
I have a three step form where each step posts to its own action.
I have a multi-step form where the form on Step3 submits to Step4.php. Step4
I have got a the following problem: I have got multi-step form where in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.