Results 1 to 12 of 12

Thread: Date and Time Validation

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Date and Time Validation

    Is there a way to mask text boxes so that they will only accept dates or times?

    If not, how can I use a validation webcontrol to ensure that a date or a time was entered into an associated text box?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    Member
    Join Date
    Jun 2002
    Location
    Madras
    Posts
    50

    Re: Date and Time Validation

    Hi simon

    include the folg code in the head tag
    <script language="javascript" src="datetimepicker.js" type="text/javascript">
    </script>

    include the folg code in the form tag near the texbox
    <A href="javascript:NewCal('txtDate','ddmmmyyyy')">

    where txtDate holds the value for the date...

    best wishes
    venkat

    Strength is Life, Weakness is Death

    - Swami Vivekananda

  3. #3
    Member
    Join Date
    Jun 2002
    Location
    Madras
    Posts
    50

    Re: Date and Time Validation

    kindly check the attachment
    Attached Files Attached Files
    venkat

    Strength is Life, Weakness is Death

    - Swami Vivekananda

  4. #4

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Date and Time Validation

    Hi,

    Thanks for your solution.

    However, I seem to be having a problem placing the following code:
    Code:
    <A href="javascript:NewCal('txtDate','ddmmmyyyy')">
    I place it beneath my text box and every label afterwards becomes a link that pops up the date picker...
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

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

    Re: Date and Time Validation

    Place an </a> after the control you want to make a picker.

  6. #6

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Date and Time Validation

    Thanks Mendhak.

    It seems it only makes labels popup the datepicker. Is that right? Can I make a button do it?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

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

    Re: Date and Time Validation

    Yes.

    In the button's tag, use the onClick="" attribute to call your javascript function that will popup your window for you.

  8. #8

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Date and Time Validation

    Oh right. Cheers!
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  9. #9

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Date and Time Validation

    This is great for inputting dates...

    But how do I actually validate that a text box holds a valid date or a valid time (in seperate boxes)?

    I know about the IsDate function...but I need to validate dates and times seperately...
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  10. #10

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Date and Time Validation

    Hmm...actually, I'm having problems with this date picker. It returns a date in a format that cannot be parsed by the Date.Parse() function...?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

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

    Re: Date and Time Validation

    Show your code and show examples of values that are being returned.

  12. #12

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Date and Time Validation

    My button that calls the function:
    Code:
    <INPUT onclick="javascript:NewCal('txtJobDate','ddmmmyyyy')" type="button" value="...">
    It returns today's date in this format: "22-Apr-2005".

    My code that retrieves and parses the date from the text box:
    VB Code:
    1. Date.Parse(txtJobDate.Text)
    My exception details are as follows:

    "System.FormatException: String was not recognized as a valid DateTime."
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

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