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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:19:18+00:00 2026-05-14T06:19:18+00:00

I am doing some client side validation in ASP.NET MVC and I found myself

  • 0

I am doing some client side validation in ASP.NET MVC and I found myself trying to do conditional validation on a set of items (ie, if the checkbox is checked then validate and visa versa). This was problematic, to say the least.

To get around this, I figured that I could “cheat” by having a hidden element that would contain all of the information for each set, thus the idea of a CSV string containing this information.

I already use a custom [HiddenRequired] attribute to validate if the hidden input contains a value, with success, but I thought as I will need to validate each piece of data in the csv, that a regular expression would solve this.

My regular expression work is extremely weak and after a good 2 hours I’ve almost given up.

This is an example of the csv string:

true,3,24,over,0.5

to explain:

  • true denotes if I should validate the rest. I need to conditionally switch in the regex using this
  • 3 and 24 are integers and will only ever fall in the range 0-24.
  • over is a string and will either be over or under
  • 0.5 is a decimal value, of unknown precision.

In the validation, all values should be present and at least of the correct type

Is there someone who can either provide such a regex or at least provide some hints, i’m really stuck!

  • 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-14T06:19:19+00:00Added an answer on May 14, 2026 at 6:19 am

    Try this regex:

    @"^(true,([01]?\d|2[0-4]),([01]?\d|2[0-4]),(over|under),\d+\.?\d+|false.*)$"
    

    I’ll try to explain it using comments. Feel free to ask if anything is unclear. =)

    @"
      ^             # start of line
       (
         true,                # literal true
        ([01]?\d              # Either 0, 1, or nothing followed by a digit
            |                 # or
         2[0-4]),             # 20 - 24
        ([01]?\d|2[0-4]),     # again
        (over|under),         # over or under
        \d+\.?\d+             # any number of digits, optional dot, any number of digits
    
       |           #... OR ... 
    
         false.*              # false followed by anything
       )
      $            # end of line
    ");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.