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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:14:12+00:00 2026-06-18T14:14:12+00:00

I have a property on a model that accepts a string value and stores

  • 0

I have a property on a model that accepts a string value and stores hex values for colors

eg: EEEEEE, 000000

I integrated a jquery plugin so that the user can use a color picker. I like it since it’s very easy to use. The problem is that when you pick a color it fills up the text box with a “#” character which then makes it easy to change the color of the textbox (for User friendliness purposes – it’s part of the plugin).

Now I want to save the value on post but the problem is the validation on the model will only accept the following characters “0-9A-F”. Which I also want to maintain (no special characters on the database).

So I figured to avoid the validation I would modify the textbox on click of the button. My questions are:

1. Is that the most efficient way?

2. If it is, how would i do it using jquery? or something else?

Let me know your thoughts.

Thanks!!!

  • 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-18T14:14:13+00:00Added an answer on June 18, 2026 at 2:14 pm

    I would use a regular expression validator as follows on your model:

    [RegularExpression(@"#([0-9][A-F])*", ErrorMessage = "Invalid Color Code")]
    

    This will include the “#” in the validation, so it will pass validation, then you can deal with the “#” on the server side, if you need to.

    If you can’t change the model validation, maybe you could do something in JavaScript when the before the form is submitted to remove the “#” from the value that is submitted.

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

Sidebar

Related Questions

I have a model that contains an Address property and Latitude / Longitude properties.
How can I override the IsValid property? I have a model that's validating as
I have an MVC application. The model has a property that is a struct
So let's say I have a small model object that contains a string that's
I have a strongly typed View that accepts a Customer model, this customer model
I am having a Property model that should contain multiple values (just Strings). With
I have a bunch of models that may or may not have a property
I have a property in my view model which returns a constant under some
I have this array property in my model and would like to see it
Currently I have a DateTime property for a model. I am using the telerik

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.