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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:11:29+00:00 2026-06-05T23:11:29+00:00

I’m having problems with client side validation on our account creation form in MVC3.

  • 0

I’m having problems with client side validation on our account creation form in MVC3. I am using data annotations on the model and the view is a partial view. Only two of the fields are being validated when I run it in a partial view. When I put the code in a regular view all of the fields are being validated.

After searching this seems to be a common problem but this case seems different because it is “half working”, meaning that I am sure the .js libs are loaded and at least sort of working. I am not loading anything with Ajax which seems to cause problems. I’m using jquery 1.5.1 and jquery.validate 1.8.0 which are IIRC what came with the install of MVC3.

Has anyone seen/solved this sort of problem?

Here is my view:

<%: Html.Hidden("Bounce", Model.Bounce)%>

<div class="editor-label"><label for="FirstName">First Name</label></div>
<div class="editor-field">
    <%: Html.TextBox("FirstName", Model.FirstName)%><br />
    <%=Html.ValidationMessage("FirstName")%>
</div>

<div class="editor-label"><label for="MiddleName">Middle Name</label></div>
<div class="editor-field">
    <%: Html.TextBox("MiddleName", Model.MiddleName)%><br />
    <%=Html.ValidationMessage("MiddleName")%>
</div>

<div class="editor-label"><label for="LastName">Last Name</label></div>
<div class="editor-field">
    <%: Html.TextBox("LastName", Model.LastName)%><br />
    <%=Html.ValidationMessage("LastName")%>
</div>

<div class="editor-label"><label for="Email">Email</label></div>
<div class="editor-field">
    <%: Html.TextBox("Email", Model.Email)%><br />
    <%=Html.ValidationMessage("Email")%>
</div>

<div class="editor-label"><label for="Password1">Password</label></div>
<div class="editor-field">
    <%: Html.Password("Password1",Model.Password1)%><br />
    <%=Html.ValidationMessage("Password1")%>
</div>

<div class="editor-label"><label for="Password2">Confirm Password</label></div>
<div class="editor-field">
    <%: Html.Password("Password2",Model.Password2)%><br />
    <%=Html.ValidationMessage("Password2")%>
</div>

<div class="form-controls"><input type="submit" value="Create Account" /></div>

The view is being rendered with

<% Html.RenderPartial("create", new CustomerCreationRequest()); %>

This is the Model

public class CustomerCreationRequest
{


    [Required(ErrorMessage = "First Name is required")]
    public string FirstName { get; set; }

    public string MiddleName { get; set; }

    [Required(ErrorMessage = "Last Name is required")]
    public string LastName { get; set; }

    [Required(ErrorMessage = "Email Address is required")]
    public string Email { get; set; }

    [Required(ErrorMessage = "Password is required")]
    public string Password1 { get; set; }

    [Compare("Password1", ErrorMessage = "The password and confirmation do not match.")]
    [Required(ErrorMessage = "Password confirmation is required")]
    public string Password2 { get; set; }

    public string Bounce { get; set; } //bounce
}

The two fields that work correctly are the Password1 and Password2 fields. Both validation rules work aswell (i.e. the Require and Compare). All other fields are not being validated and will allow the form to be submitted when blank.

Update

When looking at the generated markup it appears the data-val-required field is not present on the first 4 normal input fields but does appear on the last 2 password fields (the ones that work).

Update 2

After the form is submitted and rejected by the server the data-val-required field does appear and all of the inputs work correctly and are validating. It is only on the initial load that they are only appearing on the password fields.

  • 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-05T23:11:30+00:00Added an answer on June 5, 2026 at 11:11 pm

    I was in the processof updating the code to MVC and using strongly typed views and from previous versions there was a block of code in the controller that was writing out these named fields to ViewData. e.g.

            ViewData["loginError"] = "";
            ViewData["createError"] = "";
            ViewData["firstName"] = "";
            ViewData["middleName"] = "";
            ViewData["lastName"] = "";
            ViewData["email"] = ""; 
    

    When I removed these everything worked.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I want to construct a data frame in an Rcpp function, but when I

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.