-> Inline date entry? How? <-

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve JORDI

    -> Inline date entry? How? <-

    Hi,

    I'm looking for a way to have the user enter a date as 03042007
    for April 3rd 2007, and have that turned into 03.04.2007 as you type.

    Is there an easy way to have "03" automatically turned into "03.",
    then the next two digits into "04." to construct the valid date entry
    as you go?

    I'm trying to get the same effect as what you have, for those of you
    who know Delphi or C++Builder, an EditMask field like "##.##.#### "

    Is this possible?

    Thanks for any help

    Steve

    Sincerely,
    Steve JORDI

    (Remove the K_I_L_LSPAM from my email address)
    ------------------------------------------------
    1197 Prangins Email: stevejordiK_I_L _LSPAM@hotmail. com
    Switzerland WWW: www.sjordi.com
    ------------------------------------------------
    Volcanoes at www.sjordi.com/volcanoes
    MovieDB at www.sjmoviedb.com
    ------------------------------------------------
  • Lee

    #2
    Re: -&gt; Inline date entry? How? &lt;-

    Steve JORDI said:
    >
    >Hi,
    >
    >I'm looking for a way to have the user enter a date as 03042007
    >for April 3rd 2007, and have that turned into 03.04.2007 as you type.
    >
    >Is there an easy way to have "03" automatically turned into "03.",
    >then the next two digits into "04." to construct the valid date entry
    >as you go?
    >
    >I'm trying to get the same effect as what you have, for those of you
    >who know Delphi or C++Builder, an EditMask field like "##.##.#### "
    >
    >Is this possible?
    Mostly possible, but probably a bad idea.
    Why do you want this? If it's because that's the format that your
    back-end needs, then you MUST ensure that it's in the proper format
    on your back-end. Anything that is supposed to happen as the user
    is typing can be disabled, bypassed, or can very easily fail.

    It's also very likely to annoy those of us who don't like to see
    additional characters appearing as we type.


    --

    Comment

    • Tom Cole

      #3
      Re: -&gt; Inline date entry? How? &lt;-

      On Apr 4, 12:35 pm, Lee <REM0VElbspamt. ..@cox.netwrote :
      Steve JORDI said:
      >
      >
      >
      Hi,
      >
      I'm looking for a way to have the user enter a date as 03042007
      for April 3rd 2007, and have that turned into 03.04.2007 as you type.
      >
      Is there an easy way to have "03" automatically turned into "03.",
      then the next two digits into "04." to construct the valid date entry
      as you go?
      >
      I'm trying to get the same effect as what you have, for those of you
      who know Delphi or C++Builder, an EditMask field like "##.##.#### "
      >
      Is this possible?
      >
      Mostly possible, but probably a bad idea.
      Why do you want this? If it's because that's the format that your
      back-end needs, then you MUST ensure that it's in the proper format
      on your back-end. Anything that is supposed to happen as the user
      is typing can be disabled, bypassed, or can very easily fail.
      >
      It's also very likely to annoy those of us who don't like to see
      additional characters appearing as we type.
      >
      --
      Again, while probably not the best idea you could use the following:

      <script type="text/javascript">
      function insertDots(el) {
      if (el.value.lengt h == 2 || el.value.length == 5) {
      el.value = el.value + ".";
      }
      }
      </script>

      <input type="text" id="date" onkeypress="ins ertDots(this);"/>

      Comment

      • Steve JORDI

        #4
        Re: -&gt; Inline date entry? How? &lt;-

        >It's also very likely to annoy those of us who don't like to see
        >additional characters appearing as we type.
        Well the 3 users who will run the application asked for it.
        They come from a stand alone C++ EXE that allows them to
        just type in 03042007 and get 03.04.2007

        Of course I'll first check for oddities before storing the
        date in MySQL (and convert it to 2007-04-03 first).

        Steve

        Sincerely,
        Steve JORDI

        (Remove the K_I_L_LSPAM from my email address)
        ------------------------------------------------
        1197 Prangins Email: stevejordiK_I_L _LSPAM@hotmail. com
        Switzerland WWW: www.sjordi.com
        ------------------------------------------------
        Volcanoes at www.sjordi.com/volcanoes
        MovieDB at www.sjmoviedb.com
        ------------------------------------------------

        Comment

        • Steve JORDI

          #5
          Re: -&gt; Inline date entry? How? &lt;-

          On 4 Apr 2007 11:42:55 -0700, "Tom Cole" <tcole6@gmail.c omwrote:
          Thanks for your code sample. I should have thought about that.
          I'll modify it a bit to make sure that it correctly behaves when
          the user make changes to the field.

          Steve

          Sincerely,
          Steve JORDI

          (Remove the K_I_L_LSPAM from my email address)
          ------------------------------------------------
          1197 Prangins Email: stevejordiK_I_L _LSPAM@hotmail. com
          Switzerland WWW: www.sjordi.com
          ------------------------------------------------
          Volcanoes at www.sjordi.com/volcanoes
          MovieDB at www.sjmoviedb.com
          ------------------------------------------------

          Comment

          • Randy Webb

            #6
            Re: -&gt; Inline date entry? How? &lt;-

            Tom Cole said the following on 4/4/2007 2:42 PM:
            On Apr 4, 12:35 pm, Lee <REM0VElbspamt. ..@cox.netwrote :
            >Steve JORDI said:
            >>
            >>
            >>
            >>Hi,
            >>I'm looking for a way to have the user enter a date as 03042007
            >>for April 3rd 2007, and have that turned into 03.04.2007 as you type.
            >>Is there an easy way to have "03" automatically turned into "03.",
            >>then the next two digits into "04." to construct the valid date entry
            >>as you go?
            >>I'm trying to get the same effect as what you have, for those of you
            >>who know Delphi or C++Builder, an EditMask field like "##.##.#### "
            >>Is this possible?
            >Mostly possible, but probably a bad idea.
            >Why do you want this? If it's because that's the format that your
            >back-end needs, then you MUST ensure that it's in the proper format
            >on your back-end. Anything that is supposed to happen as the user
            >is typing can be disabled, bypassed, or can very easily fail.
            >>
            >It's also very likely to annoy those of us who don't like to see
            >additional characters appearing as we type.
            >>
            >--
            >
            Again, while probably not the best idea you could use the following:
            >
            <script type="text/javascript">
            function insertDots(el) {
            if (el.value.lengt h == 2 || el.value.length == 5) {
            el.value = el.value + ".";
            }
            }
            </script>
            >
            <input type="text" id="date" onkeypress="ins ertDots(this);"/>
            And then wonder why it doesn't work properly if you backspace over a dot?

            --
            Randy
            Chance Favors The Prepared Mind
            comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
            Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

            Comment

            • Hardono Arifanto

              #7
              Re: -&gt; Inline date entry? How? &lt;-

              On Apr 5, 6:01 am, Randy Webb <HikksNotAtH... @aol.comwrote:
              Tom Cole said the following on 4/4/2007 2:42 PM:
              >
              >
              >
              On Apr 4, 12:35 pm, Lee <REM0VElbspamt. ..@cox.netwrote :
              Steve JORDI said:
              >
              >Hi,
              >I'm looking for a way to have the user enter a date as 03042007
              >for April 3rd 2007, and have that turned into 03.04.2007 as you type.
              >Is there an easy way to have "03" automatically turned into "03.",
              >then the next two digits into "04." to construct the valid date entry
              >as you go?
              >I'm trying to get the same effect as what you have, for those of you
              >who know Delphi or C++Builder, an EditMask field like "##.##.#### "
              >Is this possible?
              Mostly possible, but probably a bad idea.
              Why do you want this? If it's because that's the format that your
              back-end needs, then you MUST ensure that it's in the proper format
              on your back-end. Anything that is supposed to happen as the user
              is typing can be disabled, bypassed, or can very easily fail.
              >
              It's also very likely to annoy those of us who don't like to see
              additional characters appearing as we type.
              >
              --
              >
              Again, while probably not the best idea you could use the following:
              >
              <script type="text/javascript">
              function insertDots(el) {
              if (el.value.lengt h == 2 || el.value.length == 5) {
              el.value = el.value + ".";
              }
              }
              </script>
              >
              <input type="text" id="date" onkeypress="ins ertDots(this);"/>
              >
              And then wonder why it doesn't work properly if you backspace over a dot?
              >
              --
              Randy
              Chance Favors The Prepared Mind
              comp.lang.javas cript FAQ -http://jibbering.com/faq/index.html
              Javascript Best Practices -http://www.JavascriptT oolbox.com/bestpractices/
              I believe it's best to replace the dots when onblur raised and re-
              check the format when onsubmit raised.

              Regards,
              Hardono Arifanto
              -----------------------
              Hardono's personal blog, exploring topics like sodeve, semalt com, sertifikasi guru depag, amazon, yhs-fh_lsonsw, huawei service centre, latest movies 2026, worempm, statementwex, content management system%!(EXTRA string=content management system), singh4a, domain registration, hearingaxt, php tutorial%!(EXTRA string=php tutorial), learn spanish online free, planetg3d, extjs, json, sencha, tools, chrome, extensions, javascript


              Comment

              • Randy Webb

                #8
                Re: -&gt; Inline date entry? How? &lt;-

                Hardono Arifanto said the following on 4/5/2007 4:50 AM:
                On Apr 5, 6:01 am, Randy Webb <HikksNotAtH... @aol.comwrote:
                >Tom Cole said the following on 4/4/2007 2:42 PM:
                <snip>
                >><input type="text" id="date" onkeypress="ins ertDots(this);"/>
                >And then wonder why it doesn't work properly if you backspace over a dot?
                >
                I believe it's best to replace the dots when onblur raised and re-
                check the format when onsubmit raised.
                No, you format it onchange. Then it doesn't get checked every time the
                field is blurred by tabbing through it. I also believe it is best to
                trim signatures.

                --
                Randy
                Chance Favors The Prepared Mind
                comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
                Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                Comment

                • marss

                  #9
                  Re: -&gt; Inline date entry? How? &lt;-


                  Randy Webb wrote:

                  I believe it's best to replace the dots when onblur raised and re-
                  check the format when onsubmit raised.
                  >
                  No, you format it onchange. Then it doesn't get checked every time the
                  field is blurred by tabbing through it. I also believe it is best to
                  trim signatures.
                  >
                  onchange will occur at least 8 times until you type 03042007, onblur
                  - 1.
                  That makes sense to use onblur event. Of course, if you have no habit
                  to go through the page by tabbing 7 additional times. :)

                  Comment

                  • Lee

                    #10
                    Re: -&gt; Inline date entry? How? &lt;-

                    marss said:
                    >
                    >
                    >Randy Webb wrote:
                    >
                    >
                    I believe it's best to replace the dots when onblur raised and re-
                    check the format when onsubmit raised.
                    >>
                    >No, you format it onchange. Then it doesn't get checked every time the
                    >field is blurred by tabbing through it. I also believe it is best to
                    >trim signatures.
                    >>
                    >
                    >onchange will occur at least 8 times until you type 03042007, onblur
                    >- 1.
                    Nonsense. RTFM.


                    --

                    Comment

                    • Michael White

                      #11
                      Re: -&gt; Inline date entry? How? &lt;-

                      Randy Webb wrote:

                      [snip]
                      >Again, while probably not the best idea you could use the following:
                      >>
                      ><script type="text/javascript">
                      > function insertDots(el) {
                      > if (el.value.lengt h == 2 || el.value.length == 5) {
                      > el.value = el.value + ".";
                      > }
                      > }
                      ></script>
                      >>
                      ><input type="text" id="date" onkeypress="ins ertDots(this);"/>
                      >
                      >
                      And then wonder why it doesn't work properly if you backspace over a dot?
                      >
                      Or if you paste into the field...
                      Mick

                      Comment

                      • Randy Webb

                        #12
                        Re: -&gt; Inline date entry? How? &lt;-

                        marss said the following on 4/5/2007 8:44 AM:
                        Randy Webb wrote:
                        >
                        >>I believe it's best to replace the dots when onblur raised and re-
                        >>check the format when onsubmit raised.
                        >No, you format it onchange. Then it doesn't get checked every time the
                        >field is blurred by tabbing through it. I also believe it is best to
                        >trim signatures.
                        >>
                        >
                        onchange will occur at least 8 times until you type 03042007, onblur
                        - 1.
                        Who fed you that load of crap? The onchange won't fire until two things
                        happen:

                        The input loses focus
                        AND
                        The value of that input has changed.

                        <input onchange="alert ('You changed me')">

                        Type 03042007 into that input and tell me how many alerts you get before
                        you navigate out of that input.
                        That makes sense to use onblur event.
                        No it doesn't.

                        --
                        Randy
                        Chance Favors The Prepared Mind
                        comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
                        Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                        Comment

                        • Dr J R Stockton

                          #13
                          Re: -&gt; Inline date entry? How? &lt;-

                          In comp.lang.javas cript message <1175712175.474 889.170790@d57g 2000hsg.go
                          oglegroups.com> , Wed, 4 Apr 2007 11:42:55, Tom Cole <tcole6@gmail.c om>
                          posted:
                          >
                          ><script type="text/javascript">
                          function insertDots(el) {
                          if (el.value.lengt h == 2 || el.value.length == 5) {
                          el.value = el.value + ".";
                          }
                          }
                          ></script>
                          If you do something like that, IMHO you should also code it to ignore
                          all non-digits (apart from whatever may terminate the input, if it does
                          not auto-terminate when full).

                          --
                          (c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
                          Web <URL:http://www.merlyn.demo n.co.uk/- FAQqish topics, acronyms & links;
                          Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
                          No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

                          Comment

                          • marss

                            #14
                            Re: -&gt; Inline date entry? How? &lt;-


                            Randy Webb wrote:
                            Who fed you that load of crap? The onchange won't fire until two things
                            I don't remember, there are many lovers to feed with own crap. :)

                            Comment

                            • Randy Webb

                              #15
                              Re: -&gt; Inline date entry? How? &lt;-

                              marss said the following on 4/6/2007 6:07 AM:
                              Randy Webb wrote:
                              >
                              >Who fed you that load of crap? The onchange won't fire until two things
                              >
                              I don't remember,
                              That's a bad thing. Now you won't know who not to listen to in the future.

                              --
                              Randy
                              Chance Favors The Prepared Mind
                              comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
                              Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

                              Comment

                              Working...