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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:31:30+00:00 2026-06-18T09:31:30+00:00

My RegisterModel has the Password Property as below: public class RegisterModel { [Required] [StringLength(100,

  • 0

My RegisterModel has the Password Property as below:

 public class RegisterModel
 {  
    [Required]
    [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 8)]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }
 }

In Register View, I have this:

<p class="message-info">
Passwords must be at least @Membership.MinRequiredPasswordLength characters long.
</p>

Though, I have changed the MinimumLength of Password to 8 characters in my RegisterModel, still it is showing only 6 on my view page as shown in screenshot below:

This is default application in MVC , I am accessing this page by account/register address.My host address is local.

How to change Password Length?

  • 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-18T09:31:31+00:00Added an answer on June 18, 2026 at 9:31 am

    Though you have changed it in your RegisterModel, notice that on your Register View, the value is coming from Membership class that is configured according to your Membership Provider in your web.config file.

    So, Check your web.config file. It has the following code:

    <membership>
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider"          
             type="System.Web.Security.SqlMembershipProvider"
             connectionStringName="ApplicationServices" 
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             requiresUniqueEmail="false"
             maxInvalidPasswordAttempts="5" 
             minRequiredPasswordLength="6"                  //Change This
             minRequiredNonalphanumericCharacters="0" 
             passwordAttemptWindow="10"
             applicationName="/" />
      </providers>
    </membership>
    

    Change minRequiredPasswordLength = "8" here too and it will work for you.

    OR

    If you don’t want to make changes in your Membership Provider, then you can still do this by writing your own Custom Attribute for MinPasswordLength as below:

    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter , AllowMultiple = false, Inherited = true)]
    public sealed class MinRequiredPasswordLengthAttribute : ValidationAttribute, IClientValidatable
    {                             
        private readonly int _minimumLength = Membership.MinRequiredPasswordLength;
        public override string FormatErrorMessage(string name)
        {
            return String.Format(CultureInfo.CurrentCulture, ErrorMessageString, name, _minimumLength);
        }    
    
        public override bool IsValid(object value)
        {                    
            string password = value.ToString();    
            return password.Length >= this._minimumLength; 
        } 
        public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context) 
        {       
            return new[]{ new ModelClientValidationStringLengthRule(FormatErrorMessage(metadata.GetDisplayName()), _minimumLength, int.MaxValue)
            };
        }
    }
    

    Then update your RegisterModel to use the MinRequiredPasswordLength DataAnnotation instead.

    [Required]        
    [MinRequiredPasswordLength(ErrorMessage = "The {0} must be at least {1} character(s) long.")]           
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }
    
    • See more at: http://timjames.me/mvc-3-password-length-dataannotation#sthash.kxyHoPep.dpuf
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a viewmodel. public class RegistrationViewModel { public RegisterModel Register { get; set;
public class RegisterViewModel { //Plain POCO Properties public RegisterModel RegisterModel { get; set; }
I have model: [Validator(typeof(RegisterValidator))] public class RegisterModel { public string Name { get; set;
I have a RegisterModel, composed of 5 SecretQuestionAndAnswerModel models public class RegisterModel { public
public ActionResult Register(RegisterModel RegisterModel, string returnUrl) { if (ModelState.IsValid) { // Attempt to register
This is my ViewModel class: public class CreatePersonModel { public string Name { get;
I have the following action in ASP.NET MVC4 public ActionResult Register(RegisterModel model) { if
This is what my Html helper looks like: namespace WebApp.WebUI { public static class
I have the following (abridged) DTO for registering a new user: [PropertiesMustMatch(Password, ConfirmPassword, ErrorMessage
I want to get UserId When registering [AllowAnonymous] [HttpPost] public ActionResult Register(RegisterModel model) {

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.