Results 1 to 4 of 4

Thread: I need textbox help

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2003
    Location
    New Hampshire, USA
    Posts
    15

    I need textbox help

    Is it possible to get a texbox on a web form to accept only numbers? I have a form that has a dollar amount that people have to add in. Because of the way it is handled in the database, the amount must be numbers (40) instead of text (forty). I've found a few people typing the amount in text and it reeks havoc in the database. Any help would be great.
    Thanks
    Brian

  2. #2
    Junior Member
    Join Date
    Oct 2005
    Posts
    22

    Re: I need textbox help

    I'm not sure if this function still exists but you could use val(yourtextbox.text), check if it returns 0 or not, if it does, just display a message box stating that they have to enter a number.

    VB Code:
    1. if val(yourtextbox.text) = 0 then
    2.     msgbox("Must enter numbers only, no text and no zeros)
    3. else
    4.      other code here
    5. end if

    of course, to use this you have to make sure that you don't need people to enter in just a zero in the textbox.

  3. #3
    Hyperactive Member
    Join Date
    Mar 2005
    Posts
    261

    Re: I need textbox help

    You can also use the Validation controls. Specifically use the compare control and set the type to integer. Or you can use a RegEx in a function, but that might be overkill [\d]

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: I need textbox help

    The validator would be the best option, IMEO.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width