Results 1 to 7 of 7

Thread: Validate Date Format

  1. #1

    Thread Starter
    Addicted Member NinaWilliam's Avatar
    Join Date
    May 2005
    Location
    @Home
    Posts
    133

    Unhappy Validate Date Format

    Hi guys,

    how can i validate the entered date format by the user in the date textbox? because the format should be (mm/dd/yyyy)..
    what if the user enters the following format (dd/mm/yyyy) and clicks on submit.. is there a way to validate in the server side other than using the 'Regular Expression Validator"??

    ASP.NET/VB.NET

    Regards,
    Nina

  2. #2
    Lively Member
    Join Date
    Feb 2005
    Posts
    121

    Re: Validate Date Format

    Hi Nina

    I dont have much knowledge of VB.NET

    iam pasting a code in C#.

    See if u can find something equivalent for this in VB.NET


    System.DateTime dt = Today;
    hDate.Value = dt.ToString("dd/MM/yyyy",DateTimeFormatInfo.InvariantInfo);

    //hDate is the name of text box

    -Sachien

  3. #3
    Addicted Member
    Join Date
    Aug 2004
    Location
    Cape Town, South Africa
    Posts
    149

    Re: Validate Date Format

    You can always use

    VB Code:
    1. Dim strDate as string = txtDate.text
    2.  
    3. If IsDate(strDate) then
    4.    '...
    5. End If

    It checks if the string strDate is a valid date.

  4. #4

    Thread Starter
    Addicted Member NinaWilliam's Avatar
    Join Date
    May 2005
    Location
    @Home
    Posts
    133

    Re: Validate Date Format

    but it is not checking the date format!!!

  5. #5
    Member CommanderEl's Avatar
    Join Date
    Feb 2005
    Location
    Adelaide, Australia
    Posts
    40

    Re: Validate Date Format

    cant you just use format("mm/dd/yyyy", stringname)
    validation on client side is easier

  6. #6
    Addicted Member jewel's Avatar
    Join Date
    Jul 2003
    Location
    truly asia
    Posts
    153

    Re: Validate Date Format

    what's wrong with regularexpressions validator?

    why not use it?

    just curious
    xoxo

  7. #7
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Re: Validate Date Format

    can you show sample how to use regularexpressions validator to validate entry on a textbox.please.TIA

    If a post has helped you then Please Rate it!

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