Results 1 to 8 of 8

Thread: How do I force a format on a txt field

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    63

    Question How do I force a format on a txt field

    Basically when my users enter a date into a text field I want to verify that it is in the following format:

    mm/dd/yy for example

    i want to make sure that I get

    05/09/01

    instead of

    5/9/01

    All suggestions appreciated in advance

    Kind Regards,
    Hakan

  2. #2
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Get the individual day, month, and year and use VAL on them (will take away any leading 0's) and then add 'em back on yourself.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    oh whoops

    Then you can use

    Format(Day_Part, "00")
    Format(Year_Part, "00")
    Format(Month_Part, "00")
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Junior Member Gold4tune's Avatar
    Join Date
    Apr 2001
    Location
    Québec
    Posts
    19

    Unhappy You will be able to find a better way, but...

    You can use a maskeditbox and check is length...
    after this you can put the text in a date to chek if it is a date (catch the error).
    But this is probably not the best way to do it.
    bye

  5. #5
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    Actually, you don't have the Format function in VBScript...

    Still haven't figured out why that is...

    Your best bet is to allow them to enter it the way they want and do validation. There is no way for you to force the format on the user.. at the end of the day, it is only a text field..

    If it is that critical that the data format be a certain way, use a control that pops up a calendar and format the date yourself based on their selection.. (That's what I did)
    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    [email protected]
    [email protected]


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    63
    The calendar control sounds fine... I have never worked with controls, or maybe I have and I am just not familiar with that term. Could you tell me were I could find a calender control and may be lead my in the direction on how I can adapt one to my code??

    Kind Regards,
    Hakan

  7. #7
    Junior Member Gold4tune's Avatar
    Join Date
    Apr 2001
    Location
    Québec
    Posts
    19

    datepicker

    use a datepicker.
    (microsoft windows common controls-2 6.0

  8. #8

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    63
    Is that something i have to download (ie. component or activex). And maybe an example on to setup the code, maybe a basic sniplet example would be great... anything would be great :-)

    Kind Regards,
    Hakan

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