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

  • Home
  • SEARCH
  • 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 8830471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:05:51+00:00 2026-06-14T08:05:51+00:00

I have a form with two fields that need to be equal (password and

  • 0

I have a form with two fields that need to be equal (password and password confirmation). I’ve created a class attribute to check that and on server side it works great. On the client side it does nothing. I need the message to appear in ValidationSummary (“Password repeated” needs to be the same as “Password”).

I realized that the easiest way to check these fields would be adding the rule manually to window.mvcClientValidationMetadata. I was trying to do that but nothing worked.

My code:

<% using (Html.BeginForm("ResetPassword", "Account", FormMethod.Post}))
   { %>
<%= Html.ValidationSummary() %>
    <div>
        <%= Html.ValidationMessageFor(m => m.Email)%>
        <%= Html.LabelFor(m => m.Email)%>
    </div>
    <div>
        <%= Html.TextBoxFor(m => m.Email)%>
        <% Html.ValidateFor(m => m.Email);%>
    </div>
    <div>
        <%= Html.ValidationMessageFor(m => m.PasswordModel.Password)%>
        <%= Html.LabelFor(m => m.PasswordModel.Password)%>
    </div>
    <div>
        <%= Html.PasswordFor(m => m.PasswordModel.Password)%>
    </div>
    <div>
        <%= Html.ValidationMessageFor(m => m.PasswordModel.PasswordRepeated)%>
        <%= Html.LabelFor(m => m.PasswordModel.PasswordRepeated)%>
    </div>
    <div>
        <%= Html.PasswordFor(m => m.PasswordModel.PasswordRepeated)%>
    </div>
    <div>
        <%= Html.ValidationMessageFor(m => m.PasswordModel.PasswordRepeated)%>
        <%= Html.LabelFor(m => m.PasswordModel.PasswordRepeated, true)%>
    </div>
<% } %>

Html.EnableClientValidation method is executed before this form is generated.

Below you’ll find the solution to my problem.

  • 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-14T08:05:52+00:00Added an answer on June 14, 2026 at 8:05 am

    The worst thing you may do is to execute exacly the same code – you’ll overwrite the existing rules.

    To add validation rules you need to put this code right after <% } %> closing using(... of your BeginForm:

    <% } %>
    
    <script type="text/javascript">
    
        window.mvcClientValidationMetadata[0]["Fields"].push( //check if the '0' is number corresponding to your form validation metadata
          {
              "FieldName": "PasswordModel.PasswordRepeated", // name attribute of the element
              "ReplaceValidationMessageContents": false,
              "ValidationMessageId": "PasswordModel_PasswordRepeated_validationMessage", //id of the ValidationMessageFor (if needed)
              "ValidationRules":
              [
                {
                    "ErrorMessage": 'Password repeated needs to be the same as Password',
                    "ValidationParameters": "#PasswordModel_Password", //'params' parameter in your validation function, can be an object
                    "ValidationType": "propertiesMustMatch" //name of the validation function placed in $.validator.methods
                }
              ]
          }
        );
    
    </script>
    

    propertiesMustMatch function checks if given fields are equal (jQuery equalTo didin’t work correctly in our system).

    There is no “Uncaught TypeError: Cannot call method ‘push’ of undefined” exception, because mvcClientValidationMetadata is generated in <script> element put where <% } %> is.

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

Sidebar

Related Questions

I have a form that contains two fields to upload files. I need to
My site has three columns. I have two fields within a form that need
I have a form that has a group of 3 text_fields. I need two
Imagine that I have a form in a flash application with two fields, input1
I have four texts fields in my form that i need them to be
I have a simple PHP script with a form that has two select fields,
I have a form and I need two fields to be the same. I
I have two fields on an MVC3 form that must represent the same value.
I have two form fields on my view page, a date input (with a
I have a form with two input text fields: <input id=ModelName_test_0 name=ModelName[test][0] type=text> <input

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.