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 425637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:23:58+00:00 2026-05-12T19:23:58+00:00

I have a registration page, and because of content issues we have to request

  • 0

I have a registration page, and because of content issues we have to request and enforce applicants giving a birthdate. So it stands to reason that this field cannot be null.

I am using jQuery to watermark the textbox to tell them that they can click it and get a jQuery UI Calendar object to pick the date. Picking the date works fine, this is not the issue.

In testing, if I try to submit the form without picking the date, I get the following error…

The parameters dictionary contains a null entry for parameter 'birthdate' of non-nullable type 'System.DateTime' for method 'System.Web.Mvc.ActionResult Register(System.String, System.String, System.String, System.String, Boolean, System.DateTime)' in 'Controllers.MembershipController'. To make a parameter optional its type should be either a reference type or a Nullable type.
Parameter name: parameters 

I don’t want to hardcode a date, the purpose of it being null is to enforce validation so that they have to select it. Any ideas? I’m including my code for the areas responsible. What is really frustrating is that the exception is being thrown before it even reaches the Register(parameters) method. The ModelState.IsValid is never getting called. I’ve tried try/catch blocks to no avail.

        <p>             
            <label for="birthday">Birthdate:</label><br />
            <%= Html.TextBox("birthdate", "Select month, year, and date last." , new { @class = "text watermarkOn", @tabindex = "5" }) %>
        </p>

    public ActionResult Register()
    {
        return View();
    } 

    [CaptchaValidator]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Register(string name, string email, string password, string validation, bool agreement, DateTime birthdate)
    {

        // attempt to validate the registration state, and if it is invalid, 
        // populate the ruleviolations and redisplay the content with the errors.
        if (ModelState.IsValid)
        {
        }

        return View();
    }

    private bool ValidateRegistration(string name, string email, string password, string validation, DateTime birthdate)
    {
        if (String.IsNullOrEmpty(name))
        {
            ModelState.AddModelError("name", "You must specify a name.");
        }
        if (String.IsNullOrEmpty(email))
        {
            ModelState.AddModelError("email", "You must specify an email address.");
        }
        if (password == null || !Text.RegularExpressions.Password(password) )
        {
            ModelState.AddModelError("password",
                String.Format(System.Globalization.CultureInfo.CurrentCulture,
                     "You must specify a password of {0} or more characters, without any whitespace characters.",6));
        }
        if (!String.Equals(password, validation, StringComparison.Ordinal))
        {
            ModelState.AddModelError("_FORM", "The new password and confirmation password do not match.");
        }
        return ModelState.IsValid;
    }
}
  • 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-05-12T19:23:59+00:00Added an answer on May 12, 2026 at 7:23 pm

    Have the birthdate parameter be a nullable DateTime, i.e., DateTime?, then check if it is null, set a model error, and rerender the view with the error when it is null.

    [CaptchaValidator]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Register(string name, string email, string password, string validation, bool agreement, DateTime? birthdate)
    {
        ValidateRegistration( name, email, password, validation, agreement, birthdate );           
        if (ModelState.IsValid)
        {
        }
        return View();
    }
    
    private bool ValidateRegistration(string name, string email, string password, string validation, DateTime? birthdate)
    {
         if (!birthdate.HasValue)
         {
             this.ModelState.AddModelError( "birthdate", "You must supply a birthdate." );
         }
    
         ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a registration page using CI that works fine. However, I encoded
I am doing a registration page coding. For that i have so many fields
I'm using ExtJS on a registration page which should have no effect on this.
So I currently have a registration.html page that holds two dates in a drop
I have a registration page that receives tokens ad parse them and login the
I'm using Zend_Form with a registration page. I have a checkbox, that if checked,
I have a form for a registration page. The form contains an image that
So here is the deal, I have a registration page, in that they need
I have a registration page with the following code below: in the views: def
I have a button on my registration Page (Windows Phone), in 30% of pushing

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.