Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Validation

Validation

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptcssvisual-studiotutorial
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tridith
    wrote on last edited by
    #1

    I was wondering if it is possible to use some type of validator from VS.net that would validate the following: The text box can only accept a 6 number/letter combination (no more no less). The first two characters can either be numbers or letters but the last 4 have to be numbers, for example the following would be accepted: (123456, PA1234). Is there a way to validate this or do I have to use javascript?? If there is a way how would I go about it? Thanks all. Chad

    M A 2 Replies Last reply
    0
    • T Tridith

      I was wondering if it is possible to use some type of validator from VS.net that would validate the following: The text box can only accept a 6 number/letter combination (no more no less). The first two characters can either be numbers or letters but the last 4 have to be numbers, for example the following would be accepted: (123456, PA1234). Is there a way to validate this or do I have to use javascript?? If there is a way how would I go about it? Thanks all. Chad

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, IMO, you can use a RequiredFieldValidator[^] to ensure that the value of the textbox is required, and you also need a RegularExpressionValidator [^] to validate the format of the value. In addition, you can use a CustomValidator [^] to provide your own logic.

      1 Reply Last reply
      0
      • T Tridith

        I was wondering if it is possible to use some type of validator from VS.net that would validate the following: The text box can only accept a 6 number/letter combination (no more no less). The first two characters can either be numbers or letters but the last 4 have to be numbers, for example the following would be accepted: (123456, PA1234). Is there a way to validate this or do I have to use javascript?? If there is a way how would I go about it? Thanks all. Chad

        A Offline
        A Offline
        azam316
        wrote on last edited by
        #3

        its pretty simple. just use a regular expression validator, and associate it with your textbox. the only tricky part is the regular expression! and luckily i have it! its: ^\w{2}\d{4}$ ive not tested thoroughly, but i think it will work. good luck! ☺«««DTA»»»☺

        T B 2 Replies Last reply
        0
        • A azam316

          its pretty simple. just use a regular expression validator, and associate it with your textbox. the only tricky part is the regular expression! and luckily i have it! its: ^\w{2}\d{4}$ ive not tested thoroughly, but i think it will work. good luck! ☺«««DTA»»»☺

          T Offline
          T Offline
          Tridith
          wrote on last edited by
          #4

          Thanks guys for the posts I found this one to work very well: ^[a-zA-Z0-9]{2}\d{4}$ I was wondering where you can go to look for what that above means, i dont understand what ^, {}, d and there are a lot more taht I have no idea what they do. Thanks again. Chad

          G 1 Reply Last reply
          0
          • A azam316

            its pretty simple. just use a regular expression validator, and associate it with your textbox. the only tricky part is the regular expression! and luckily i have it! its: ^\w{2}\d{4}$ ive not tested thoroughly, but i think it will work. good luck! ☺«««DTA»»»☺

            B Offline
            B Offline
            BECK7
            wrote on last edited by
            #5

            is there any way to set one regular expression to various controls?.... BECK 7

            1 Reply Last reply
            0
            • T Tridith

              Thanks guys for the posts I found this one to work very well: ^[a-zA-Z0-9]{2}\d{4}$ I was wondering where you can go to look for what that above means, i dont understand what ^, {}, d and there are a lot more taht I have no idea what they do. Thanks again. Chad

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              In a RegularExpressionValidator the ^ and $ is implied, so the pattern to use is: [a-zA-Z0-9]{2}\d{4} (or [a-zA-Z\d]{2}\d{4}) Here is the reference to the regular expression syntax: js56jsgrpregexpsyntax --- b { font-weight: normal; }

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups