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. Input Text Mask

Input Text Mask

Scheduled Pinned Locked Moved Web Development
javascriptregexhelpquestion
4 Posts 3 Posters 2 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.
  • J Offline
    J Offline
    jcrussell
    wrote on last edited by
    #1

    Hey all I have a textbox with a max length of 5 the first three chars must be uppercase letters between [A-Z] the final two chars must be between [0-9] I am trying to do this as a regex function in the onChange Event using Javascript, but my Regular Expressions aren't very good. currently I split the textbox.text into two string variables str1 = orgID.substr(0,3); // first three chars str2 = orgID.substr(4,5); // last two chars Then I run a (very) simple regex expression on each of these substrings. How would I do this formatting without breaking orgID into 2 substrings? Thanks for help Jason -- modified at 20:23 Monday 10th April, 2006

    A W 2 Replies Last reply
    0
    • J jcrussell

      Hey all I have a textbox with a max length of 5 the first three chars must be uppercase letters between [A-Z] the final two chars must be between [0-9] I am trying to do this as a regex function in the onChange Event using Javascript, but my Regular Expressions aren't very good. currently I split the textbox.text into two string variables str1 = orgID.substr(0,3); // first three chars str2 = orgID.substr(4,5); // last two chars Then I run a (very) simple regex expression on each of these substrings. How would I do this formatting without breaking orgID into 2 substrings? Thanks for help Jason -- modified at 20:23 Monday 10th April, 2006

      A Offline
      A Offline
      alexey N
      wrote on last edited by
      #2

      You can use direct access to chars: str.charAt(index);

      1 Reply Last reply
      0
      • J jcrussell

        Hey all I have a textbox with a max length of 5 the first three chars must be uppercase letters between [A-Z] the final two chars must be between [0-9] I am trying to do this as a regex function in the onChange Event using Javascript, but my Regular Expressions aren't very good. currently I split the textbox.text into two string variables str1 = orgID.substr(0,3); // first three chars str2 = orgID.substr(4,5); // last two chars Then I run a (very) simple regex expression on each of these substrings. How would I do this formatting without breaking orgID into 2 substrings? Thanks for help Jason -- modified at 20:23 Monday 10th April, 2006

        W Offline
        W Offline
        WoutL
        wrote on last edited by
        #3

        I am not sure what you exactly want, but if you only want to test the format of the string you can use: var re = /[A-Z]{3}\d{2}/; if(re.test(orgID)) { ... } Wout Louwers

        J 1 Reply Last reply
        0
        • W WoutL

          I am not sure what you exactly want, but if you only want to test the format of the string you can use: var re = /[A-Z]{3}\d{2}/; if(re.test(orgID)) { ... } Wout Louwers

          J Offline
          J Offline
          jcrussell
          wrote on last edited by
          #4

          This is perfect :) It is even case sensitive :cool: Thanks alot Jason

          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