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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:01:48+00:00 2026-05-26T03:01:48+00:00

I need to add a field validator, the admin of the website sets the

  • 0

I need to add a field validator, the admin of the website sets the number of characters of a textbox in admin and then… in the front side users can only type upto the number of characters specified by the admin.

In the fron end i aleady pull the number from the database but now i am not sure how to create a validator where i can set the value say:

pseudocode

Get the validator
 set the validator to validate these maximum number of characters
     myValidator.setamaxnumber = mydbvalue;
     error message = Only + mydbvalue + charaters are accepted.

I hope you understand what i want to do. If not, no need to do a negative vote post your question and i will try my best to supply more information

Thanks a million

  • 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-26T03:01:49+00:00Added an answer on May 26, 2026 at 3:01 am

    Try using the RegularExpressionValidator control like so:

    Markup

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:RegularExpressionValidator ID="MaxLengthValidator" runat="server" ControlToValidate="TextBox1"></asp:RegularExpressionValidator>
    

    Codebehind

    protected void Page_Load(object sender, EventArgs e)
    {
        var maxLength = 10;
        MaxLengthValidator.ValidationExpression = @"^[\s\S]{0," + maxLength.ToString() + "}$";
        MaxLengthValidator.ErrorMessage = string.Format("Only {0} charaters are accepted.", maxLength);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In asp.net, I need to add a validator to a textbox that forces the
I need to add an invite users functionality to my social networking application so
I m using jquery validator plugin. i need to validate some field with some
I have an input field which is localized . I need to add a
I have the following admin setup so that I can add/edit a user and
During one of my project i need to add required field validation on the
I need add a new user group for mediawiki. The new group has more
need to add a 2nd css stylesheet to a page. do i add a
I need to add CRRedist2008_x86.msi to my deployment project as it is a requirement
I need to add css height to each page dynamically with jQuery. So far

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.