formatting date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phpmel
    New Member
    • Oct 2007
    • 69

    formatting date

    Hi guys,

    I wanted to find out how i can do this.
    I have a textbox on a form. I want the user to enter the date in the format YYYY-MM-DD.
    when the user types 4 digits i want a dash('-') to be inserted and then the user will type the other 2 digits and another dash would be inserted and then the next 2 digits can be typed.
    How do i insert the dash?

    Please help
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    html/css cannot do this. Check on the javascript forum.

    Comment

    • phpmel
      New Member
      • Oct 2007
      • 69

      #3
      formatting date

      Hi guys,

      I wanted to find out how i can do this.
      I have a textbox on a form. I want the user to enter the date in the format YYYY-MM-DD.
      when the user types 4 digits i want a dash('-') to be inserted and then the user will type the other 2 digits and another dash would be inserted and then the next 2 digits can be typed.
      How do i insert the dash?

      Please help

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Keep checking the input on every key press.

        Once the length is 4, add a dash: inputbox.value+ ="-".

        Comment

        • nirchuk
          New Member
          • Nov 2007
          • 4

          #5
          You cant do that in HTML/CSS

          You can do that in JavaScript

          Comment

          Working...