Validations......

Discussion in 'ASP .Net' started by Gary Smith, Feb 15, 2004.

  1. Gary Smith

    Gary Smith Guest

    In my ASP.Net application I am using textbox for user to enter the date.
    How to enforce the user to enter only the numeric values( and "/" character)
    in this edit box ?
    Thanks for your suggestions.
    Gary
    Gary Smith, Feb 15, 2004
    #1
    1. Advertising

  2. Gary Smith

    Scott M. Guest

    Use a regular expression validator with the date format you want as its
    ValidationExpression.


    "Gary Smith" <> wrote in message
    news:%...
    > In my ASP.Net application I am using textbox for user to enter the date.
    > How to enforce the user to enter only the numeric values( and "/"

    character)
    > in this edit box ?
    > Thanks for your suggestions.
    > Gary
    >
    >
    Scott M., Feb 15, 2004
    #2
    1. Advertising

  3. Gary Smith

    Jon Guest

    Hi Gary,
    how would you deal with different date formats though, eg
    today is 15/02/04 where I am (UK) but 02/15/04 in USA. I'd say it's much
    safer to present dropdowns for day/month/year and then build the date server
    side. You could also add some javascript so a user can't enter something
    like 30 February

    Jon

    "Gary Smith" <> wrote in message
    news:%...
    > In my ASP.Net application I am using textbox for user to enter the date.
    > How to enforce the user to enter only the numeric values( and "/"

    character)
    > in this edit box ?
    > Thanks for your suggestions.
    > Gary
    >
    >
    Jon, Feb 15, 2004
    #3
  4. Gary Smith

    Peter Blum Guest

    The CompareValidator handles this correctly. Set its Operator property to
    "DataTypeCheck" and Type="Date". The page's current thread provides the
    CultureInfo object that dictates the date format. Usually users set the <@
    Page Culture= > attribute. In your case, Culture="en-GB".

    FYI: If you are looking for a more powerful date text box that handles
    formatting, localization, validation and has a popup calendar, look at my
    product "Peter's Date Package" at
    http://www.peterblum.com/datecontrols/home.aspx.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Jon" <> wrote in message
    news:...
    > Hi Gary,
    > how would you deal with different date formats though, eg
    > today is 15/02/04 where I am (UK) but 02/15/04 in USA. I'd say it's much
    > safer to present dropdowns for day/month/year and then build the date

    server
    > side. You could also add some javascript so a user can't enter something
    > like 30 February
    >
    > Jon
    >
    > "Gary Smith" <> wrote in message
    > news:%...
    > > In my ASP.Net application I am using textbox for user to enter the date.
    > > How to enforce the user to enter only the numeric values( and "/"

    > character)
    > > in this edit box ?
    > > Thanks for your suggestions.
    > > Gary
    > >
    > >

    >
    >
    Peter Blum, Feb 15, 2004
    #4
  5. Gary Smith

    Scott M. Guest

    I disagree. You simply put next to the textbox how you want the data
    entered: _________ (mm/dd/yyyy). This is easy for the user of the page
    to understand and easy to set up the validation control to check for.


    "Jon" <> wrote in message
    news:...
    > Hi Gary,
    > how would you deal with different date formats though, eg
    > today is 15/02/04 where I am (UK) but 02/15/04 in USA. I'd say it's much
    > safer to present dropdowns for day/month/year and then build the date

    server
    > side. You could also add some javascript so a user can't enter something
    > like 30 February
    >
    > Jon
    >
    > "Gary Smith" <> wrote in message
    > news:%...
    > > In my ASP.Net application I am using textbox for user to enter the date.
    > > How to enforce the user to enter only the numeric values( and "/"

    > character)
    > > in this edit box ?
    > > Thanks for your suggestions.
    > > Gary
    > >
    > >

    >
    >
    Scott M., Feb 15, 2004
    #5
  6. Gary Smith

    Jon Guest

    right, my post was from a user's standpoint rather than a programming one.
    As a user I dislike sites that ask for dates as mm/dd/yy - it's this
    attitude that everyone has to do things the American way. Just my 2 pence
    (cents :)

    Jon

    "Peter Blum" <> wrote in message
    news:...
    > The CompareValidator handles this correctly. Set its Operator property to
    > "DataTypeCheck" and Type="Date". The page's current thread provides the
    > CultureInfo object that dictates the date format. Usually users set the <@
    > Page Culture= > attribute. In your case, Culture="en-GB".
    >
    > FYI: If you are looking for a more powerful date text box that handles
    > formatting, localization, validation and has a popup calendar, look at my
    > product "Peter's Date Package" at
    > http://www.peterblum.com/datecontrols/home.aspx.
    >
    > --- Peter Blum
    > www.PeterBlum.com
    > Email:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "Jon" <> wrote in message
    > news:...
    > > Hi Gary,
    > > how would you deal with different date formats though, eg
    > > today is 15/02/04 where I am (UK) but 02/15/04 in USA. I'd say it's much
    > > safer to present dropdowns for day/month/year and then build the date

    > server
    > > side. You could also add some javascript so a user can't enter something
    > > like 30 February
    > >
    > > Jon
    > >
    > > "Gary Smith" <> wrote in message
    > > news:%...
    > > > In my ASP.Net application I am using textbox for user to enter the

    date.
    > > > How to enforce the user to enter only the numeric values( and "/"

    > > character)
    > > > in this edit box ?
    > > > Thanks for your suggestions.
    > > > Gary
    > > >
    > > >

    > >
    > >

    >
    >
    Jon, Feb 16, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jon Paugh

    vbscript validations and .NET

    Jon Paugh, Dec 17, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    437
    bruce barker
    Dec 17, 2003
  2. DotNetJunkies User
    Replies:
    1
    Views:
    352
    Teemu Keiski
    May 1, 2004
  3. Murat YILMAZ

    Page client validations are not working...

    Murat YILMAZ, Oct 28, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,814
    Scott Allen
    Oct 31, 2004
  4. rvsraghu

    Datalist validations. . .

    rvsraghu, Apr 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    453
    Karl Seguin
    Apr 2, 2005
  5. anil kumar via .NET 247

    how to close asp.net web page with out effect of validations

    anil kumar via .NET 247, Apr 7, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    6,565
    Shawn H. Mesiatowsky
    Apr 7, 2005
Loading...

Share This Page