2 text box validations cause loop trap

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Abby Lee

    2 text box validations cause loop trap

    I have back to back text boxes used to create university account numbers. I'm
    actually creating them with a script so they can create as many account
    numbers as they need.

    <edited and cut down script>
    <input type="text" size="5" name="fund_1" onBlur="checkac t(this)">
    <input type="text" size="5" name="org_1" onBlur="checkac t(this)">"

    function checkact(entry) {
    if (!Is_In_Format( entry.value, "dddddd")){
    alert("Format: 123456");
    entry.focus();
    }
    }


    It works fine UNLESS...they enter the wrong format in "fund_1" and click
    the "org_1" text box. They get an alert message (because "fund_1" is wrong)
    and the script moves the focus back to "fund_1" which gives them an alert
    message becuse they did not properly fill out "org_1"...w ell, you see where
    I'm going with this.

    How do you handle this type of thing?
  • kaeli

    #2
    Re: 2 text box validations cause loop trap

    In article <uiucguest.2004 0204165559$5a9d @news.ks.uiuc.e du>, abbylee26
    @hotmail.com enlightened us with...[color=blue]
    > It works fine UNLESS...they enter the wrong format in "fund_1" and click
    > the "org_1" text box. They get an alert message (because "fund_1" is wrong)
    > and the script moves the focus back to "fund_1" which gives them an alert
    > message becuse they did not properly fill out "org_1"...w ell, you see where
    > I'm going with this.
    >
    > How do you handle this type of thing?
    >[/color]

    How do *I* handle it? I only validate on form submission, not on blur,
    because I've had numerous problems with onblur (cross-browser).

    How might you handle it?
    Blanks don't fire blur handlers, then check fields again in the form's
    onSubmit (assuming/if blanks aren't allowed).

    onBlur="if (this.value&&th is.value.length >0) checkact(this)"

    --
    --
    ~kaeli~
    If a book about failures doesn't sell, is it a success?



    Comment

    • Lee

      #3
      Re: 2 text box validations cause loop trap

      Abby Lee said:[color=blue]
      >
      >I have back to back text boxes used to create university account numbers. I'm
      >actually creating them with a script so they can create as many account
      >numbers as they need.
      >
      ><edited and cut down script>
      ><input type="text" size="5" name="fund_1" onBlur="checkac t(this)">
      ><input type="text" size="5" name="org_1" onBlur="checkac t(this)">"
      >
      >function checkact(entry) {
      > if (!Is_In_Format( entry.value, "dddddd")){
      > alert("Format: 123456");
      > entry.focus();
      > }
      >}
      >
      >
      >It works fine UNLESS...they enter the wrong format in "fund_1" and click
      >the "org_1" text box. They get an alert message (because "fund_1" is wrong)
      >and the script moves the focus back to "fund_1" which gives them an alert
      >message becuse they did not properly fill out "org_1"...w ell, you see where
      >I'm going with this.
      >
      >How do you handle this type of thing?[/color]


      By never, ever, validating onBlur. Use onChange, instead.

      Comment

      • Abby Lee

        #4
        Re: 2 text box validations cause loop trap

        Lee <REM0VElbspamtr ap@cox.net> writes:
        [color=blue]
        > Abby Lee said:[color=green]
        > >
        > >I have back to back text boxes used to create university account numbers.
        > >I'm
        > >actually creating them with a script so they can create as many account
        > >numbers as they need.
        > >
        > ><edited and cut down script>
        > ><input type="text" size="5" name="fund_1" onBlur="checkac t(this)">
        > ><input type="text" size="5" name="org_1" onBlur="checkac t(this)">"
        > >
        > >function checkact(entry) {
        > > if (!Is_In_Format( entry.value, "dddddd")){
        > > alert("Format: 123456");
        > > entry.focus();
        > > }
        > >}
        > >
        > >
        > >It works fine UNLESS...they enter the wrong format in "fund_1" and click
        > >the "org_1" text box. They get an alert message (because "fund_1" is
        > >wrong)
        > >and the script moves the focus back to "fund_1" which gives them an alert
        > >message becuse they did not properly fill out "org_1"...w ell, you see
        > >where
        > >I'm going with this.
        > >
        > >How do you handle this type of thing?[/color]
        >
        >
        > By never, ever, validating onBlur. Use onChange, instead.
        >[/color]

        Funny thing...using the onChange "entry.focus(); " no longer works.

        Comment

        • Abby Lee

          #5
          Re: 2 text box validations cause loop trap

          kaeli <tiny_one@NOSPA M.comcast.net> writes:
          [color=blue]
          > In article <uiucguest.2004 0204165559$5a9d @news.ks.uiuc.e du>, abbylee26
          > @hotmail.com enlightened us with...[color=green]
          > > It works fine UNLESS...they enter the wrong format in "fund_1" and click
          > > the "org_1" text box. They get an alert message (because "fund_1" is
          > > wrong)
          > > and the script moves the focus back to "fund_1" which gives them an alert
          > >
          > > message becuse they did not properly fill out "org_1"...w ell, you see
          > > where
          > > I'm going with this.
          > >
          > > How do you handle this type of thing?
          > >[/color]
          >
          > How do *I* handle it? I only validate on form submission, not on blur,
          > because I've had numerous problems with onblur (cross-browser).
          >
          > How might you handle it?
          > Blanks don't fire blur handlers, then check fields again in the form's
          > onSubmit (assuming/if blanks aren't allowed).
          >
          > onBlur="if (this.value&&th is.value.length >0) checkact(this)"
          >[/color]

          I understand what you are saying...howeve r, I must varify they are using a 6
          digit number for other parts of the form to work for them before the page is
          submited.

          Comment

          • kaeli

            #6
            Re: 2 text box validations cause loop trap

            In article <uiucguest.2004 0204190812$13e0 @news.ks.uiuc.e du>, abbylee26
            @hotmail.com enlightened us with...[color=blue][color=green]
            > >[/color]
            >
            > Funny thing...using the onChange "entry.focus(); " no longer works.
            >[/color]

            It has something to do with the event bubbling - I forget the exact
            cause, but it's why I didn't use onChange. :)

            Try modifying your function and call to

            <input type="text" size="5" name="fund_1" id="fund_1" onBlur="checkac t
            (this.id)">

            function checkact(entry) {
            if (document.getEl ementById) {
            e = document.getEle mentById(entry) ;
            if (!Is_In_Format( e.value, "dddddd")){
            alert("Format: 123456");
            e.focus();
            }
            }
            }

            Assumes your clients have DOM browsers, though. Mine had NN4 for the
            longest time, and this won't work in that.

            --
            --
            ~kaeli~
            Synonym: the word you use in place of a word you can't
            spell.



            Comment

            • Abby Lee

              #7
              Re: 2 text box validations cause loop trap

              kaeli <tiny_one@NOSPA M.comcast.net> writes:
              [color=blue]
              > In article <uiucguest.2004 0204190812$13e0 @news.ks.uiuc.e du>, abbylee26
              > @hotmail.com enlightened us with...[color=green][color=darkred]
              > > >[/color]
              > >
              > > Funny thing...using the onChange "entry.focus(); " no longer works.
              > >[/color]
              >
              > It has something to do with the event bubbling - I forget the exact
              > cause, but it's why I didn't use onChange. :)
              >
              > Try modifying your function and call to
              >
              > <input type="text" size="5" name="fund_1" id="fund_1" onBlur="checkac t
              > (this.id)">
              >
              > function checkact(entry) {
              > if (document.getEl ementById) {
              > e = document.getEle mentById(entry) ;
              > if (!Is_In_Format( e.value, "dddddd")){
              > alert("Format: 123456");
              > e.focus();
              > }
              > }
              > }
              >
              > Assumes your clients have DOM browsers, though. Mine had NN4 for the
              > longest time, and this won't work in that.
              >[/color]

              Thank you.
              It's so nice that I'm creating this application for our intranet...ever yone
              has IE6.

              Comment

              • kaeli

                #8
                Re: 2 text box validations cause loop trap

                In article <uiucguest.2004 0204215000$2c7a @news.ks.uiuc.e du>, abbylee26
                @hotmail.com enlightened us with...[color=blue]
                >
                > Thank you.
                > It's so nice that I'm creating this application for our intranet...ever yone
                > has IE6.[/color]

                I know, I love that. :)
                We have NN6 and IE6.
                It's nice to know everyone has to have certain browsers. I have a lot
                more leeway.
                Although I test my stuff in Mozilla and Opera 7 too just for kicks
                sometimes. I have learned some valuable things doing that. JIC I ever
                get a job where it ISN'T intranet. heh

                --
                --
                ~kaeli~
                Local Area Network in Australia:... the LAN down under.



                Comment

                Working...