best-practice form checking

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

    #1

    best-practice form checking

    I've constructed this form so that if Javascript is disaabled it will
    show a typical <input type="submit"> button, BUT using the <noscript>
    tag. Why is this a problem and what's a viable solution? i'm not sure
    of the best way to do this so help is very much appreciated; snide,
    smartass, unhelpful comments are useless. Please keep them to
    yourself.
  • Brian

    #2
    Re: best-practice form checking

    cruiserweight wrote:
    [color=blue]
    > I've constructed this form so that if Javascript is disaabled it
    > will show a typical <input type="submit"> button, BUT using the
    > <noscript> tag. Why is this a problem and what's a viable solution?[/color]

    The question is why you've done this. Why is a submit button only
    available in no-js situations?
    [color=blue]
    > snide, smartass, unhelpful comments are useless. Please keep them
    > to yourself.[/color]


    Best not to cop an attitude, especially before you've gotten any help.

    --
    Brian (remove ".invalid" to email me)

    Comment

    • Steve Pugh

      #3
      Re: best-practice form checking

      bayon86@yahoo.c om (cruiserweight) wrote:
      [color=blue]
      >I've constructed this form so that if Javascript is disaabled it will
      >show a typical <input type="submit"> button, BUT using the <noscript>
      >tag.[/color]

      What happens for users who do have JavaScript enabled? Do they get a
      submit button at all?

      In what way does it benefit some users _not_ to have an instantly
      recognisable submit button?
      [color=blue]
      >Why is this a problem and what's a viable solution?[/color]

      <noscript> is a blunt instrument. What if the user's browser supports
      JavaScript but doesn't support all the individual parts that need to
      be used to do whatever it is that you're doing?
      [color=blue]
      >i'm not sure
      >of the best way to do this so help is very much appreciated;[/color]

      Write the form in HTML with a server side script that handles the
      submission fully (including any checking that needs to be done).

      Then add JavaScript on top of that to perform client side checking
      (the time saved will benefit those who have JS enabled). This

      JavaScript should be triggered via the onsubmit event handler of the
      form (or equivalent event listener methods), not via the onclick event
      handler of a particular button, etc.

      This JavaScript should also be written so that the browser falls back
      to submitting the form to the server in cases where the JavaScript can
      not be processed - it should only ever not submit the form if a
      definite error is detected in the data.

      Technical questions on JS would be better directed to
      comp.lang.javas cript

      Steve

      --
      "My theories appal you, my heresies outrage you,
      I never answer letters and you don't like my tie." - The Doctor

      Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

      Comment

      • Harlan Messinger

        #4
        Re: best-practice form checking

        bayon86@yahoo.c om (cruiserweight) wrote:
        [color=blue]
        >I've constructed this form so that if Javascript is disaabled it will
        >show a typical <input type="submit"> button, BUT using the <noscript>
        >tag. Why is this a problem and what's a viable solution? i'm not sure
        >of the best way to do this so help is very much appreciated; snide,
        >smartass, unhelpful comments are useless.[/color]

        Is it being a smartass, and therefore useless, to bring to your
        attention the fact that only a psychic can help you if you keep the
        trouble-causing code a secret?
        [color=blue]
        > Please keep them to
        >yourself.[/color]

        I'm so profoundly sorry for having wasted your time, but I couldn't
        resist. May we now have *your* apologies for having wasted *our* time
        by asking for help without providing relevant information?

        --
        Harlan Messinger
        Remove the first dot from my e-mail address.
        Veuillez ôter le premier point de mon adresse de courriel.

        Comment

        • cruiserweight

          #5
          Re: best-practice form checking

          Harlan Messinger <hmessinger.rem ovethis@comcast .net> wrote in message news:<7e7nb09ci pcsqinkaq7pjcbk 9nfb4tgeh0@4ax. com>...[color=blue]
          > bayon86@yahoo.c om (cruiserweight) wrote:
          >[color=green]
          > >I've constructed this form so that if Javascript is disaabled it will
          > >show a typical <input type="submit"> button, BUT using the <noscript>
          > >tag. Why is this a problem and what's a viable solution? i'm not sure
          > >of the best way to do this so help is very much appreciated; snide,
          > >smartass, unhelpful comments are useless.[/color]
          >
          > Is it being a smartass, and therefore useless, to bring to your
          > attention the fact that only a psychic can help you if you keep the
          > trouble-causing code a secret?
          >[color=green]
          > > Please keep them to
          > >yourself.[/color]
          >
          > I'm so profoundly sorry for having wasted your time, but I couldn't
          > resist. May we now have *your* apologies for having wasted *our* time
          > by asking for help without providing relevant information?[/color]


          Point well-taken. Apologies all around. The form is at
          http://www.veiyotonle.com/printablem...enu=printables. I put a
          regular submit button inside noscript tags, and then used javascript
          to writeln the code for the javascript button. fields are checked in
          javascript (if enabled) and on the server. I've read in these groups
          recently, i forget where, that this is not a very good way to do
          things. I was to find a better way. Again, sorry for the a-hole
          comments.

          Comment

          • Pierre Goiffon

            #6
            Re: best-practice form checking

            "cruiserwei ght" <bayon86@yahoo. com> a écrit dans le message de
            news:18bdba0a.0 406020430.57c42 9a6@posting.goo gle.com[color=blue]
            > I put a
            > regular submit button inside noscript tags, and then used javascript
            > to writeln the code for the javascript button. fields are checked in
            > javascript (if enabled) and on the server.[/color]

            Err, why don't use the onSubmit event ? It works perfectly for non enabled
            javascript ua as for enabled ones !

            Please see :


            Comment

            • Harlan Messinger

              #7
              Re: best-practice form checking

              "Pierre Goiffon" <pgoiffon@nowhe re.invalid> wrote:
              [color=blue]
              >"cruiserweight " <bayon86@yahoo. com> a écrit dans le message de
              >news:18bdba0a. 0406020430.57c4 29a6@posting.go ogle.com[color=green]
              >> I put a
              >> regular submit button inside noscript tags, and then used javascript
              >> to writeln the code for the javascript button. fields are checked in
              >> javascript (if enabled) and on the server.[/color]
              >
              >Err, why don't use the onSubmit event ?[/color]

              The onsubmit attribute has nothing to do with whether a button is
              drawn via Javascript or directly with HTML.
              [color=blue]
              > It works perfectly for non enabled
              >javascript ua as for enabled ones ![/color]

              Assuming we *are* talking about onsubmit, Javascript certainly is
              required for onsubmit to have any effect.
              [color=blue]
              >
              >Please see :
              >http://devedge.netscape.com/library/...s.html#1121163[/color]

              ....where it says, "Executes JavaScript code when a submit event
              occurs; that is, when a user submits a form." In other words,
              Javascript has to be enabled for it to do anything.

              --
              Harlan Messinger
              Remove the first dot from my e-mail address.
              Veuillez ôter le premier point de mon adresse de courriel.

              Comment

              • Brian

                #8
                Re: best-practice form checking

                cruiserweight wrote:
                [color=blue][color=green][color=darkred]
                >>> I've constructed this form so that if Javascript is disaabled
                >>> it will show a typical <input type="submit"> button, BUT using
                >>> the <noscript> tag.[/color][/color][/color]
                [color=blue]
                > regular submit button inside noscript tags, and then used
                > javascript to writeln the code for the javascript button. fields
                > are checked in javascript (if enabled) and on the server.[/color]

                Too complicated, and too prone to failure. Create a form using only
                html, forget completely about js. Create whatever validation you need
                on the server. When the form works perfectly without js, add a js
                validation routine, and attach it to the form's onsubmit handler. Have
                the routine return false if there's an error.

                Deze pagina bestaat niet of is niet meer beschikbaar. Oude XS4ALL-homepages zijn soms nog terug te vinden via webarchieven.


                --
                Brian (remove ".invalid" to email me)

                Comment

                • Pierre Goiffon

                  #9
                  Re: best-practice form checking

                  "Harlan Messinger" <hmessinger.rem ovethis@comcast .net> a écrit dans le
                  message de news:hoqsb0ht7c r6cee146qipmptc fjmrrhnh8@4ax.c om[color=blue][color=green]
                  >> Err, why don't use the onSubmit event ?[/color]
                  >
                  > The onsubmit attribute has nothing to do with whether a button is
                  > drawn via Javascript or directly with HTML.[/color]

                  Well I wrote my post a little to fast. As I understand it, but it's not
                  perfectly clear, it seems Cruiserweight is using writeln to had JavaScript
                  checks for his form. If this is it, it could be replaced by a function
                  called in the onSubmit event. In fact I was answering that because
                  unfortunately JavaScript validation that blocks non-enabled Javascript ua is
                  very common. Just what I guessed reading Cruiserweight.

                  By the way Cruiserweight, maybe you should explain exactly what is the
                  difference between the normal html submit button and what is written via JS
                  ? Is it just Javascript validation, or is there another things ?

                  Comment

                  • Pierre Goiffon

                    #10
                    Re: best-practice form checking

                    Oops forgot to say...

                    "Harlan Messinger" <hmessinger.rem ovethis@comcast .net> a écrit dans le
                    message de news:hoqsb0ht7c r6cee146qipmptc fjmrrhnh8@4ax.c om[color=blue][color=green]
                    >> Err, why don't use the onSubmit event ?[/color]
                    >
                    > Javascript has to be enabled for it to do anything.[/color]

                    Yes exactly, but Cruiserweight said there are a client side checking via
                    JavaScript, plus a server side one :
                    [color=blue][color=green][color=darkred]
                    >>> fields are checked in
                    >>> javascript (if enabled) and on the server.[/color][/color][/color]

                    Comment

                    • Steve Pugh

                      #11
                      Re: best-practice form checking

                      bayon86@yahoo.c om (cruiserweight) wrote:[color=blue]
                      >
                      >Point well-taken. Apologies all around. The form is at
                      >http://www.veiyotonle.com/printablem...enu=printables. I put a
                      >regular submit button inside noscript tags, and then used javascript
                      >to writeln the code for the javascript button. fields are checked in
                      >javascript (if enabled) and on the server. I've read in these groups
                      >recently, i forget where, that this is not a very good way to do
                      >things.[/color]

                      I gave one possible reason in my earlier post. Another is that your
                      way uses more code than the alternative.
                      [color=blue]
                      > I was to find a better way.[/color]

                      Change:
                      if ( good2go > 0) {
                      document.printf orm.submit();
                      return false;
                      }

                      to:
                      if ( good2go > 0) { return true; }

                      Change:
                      <form name="printform " method="post" action="print.h tml?menu=other" >
                      to:
                      <form name="printform " method="post" action="print.h tml?menu=other"
                      onclick="return validate();">

                      Change:
                      <noscript><p class="body"><i nput type="submit" value="Print Selected"
                      name="Print Selected" /></p></noscript>
                      <script type="text/javascript"><!--
                      document.writel n ("<div><a href=\"#\" onClick=\"retur n validate();\"
                      class=\"button\ ">Print Selected</a></div>");
                      // --></script>

                      to:
                      <p class="body"><i nput type="submit" value="Print Selected"
                      name="Print Selected" /></p>

                      Steve

                      --
                      "My theories appal you, my heresies outrage you,
                      I never answer letters and you don't like my tie." - The Doctor

                      Steve Pugh <steve@pugh.net > <http://steve.pugh.net/>

                      Comment

                      • cruiserweight

                        #12
                        Re: best-practice form checking

                        Brian <usenet3@juliet remblay.com.inv alid> wrote in message news:<40bb7930@ news-1.oit.umass.edu >...[color=blue]
                        > cruiserweight wrote:
                        >[color=green]
                        > > I've constructed this form so that if Javascript is disaabled it
                        > > will show a typical <input type="submit"> button, BUT using the
                        > > <noscript> tag. Why is this a problem and what's a viable solution?[/color]
                        >
                        > The question is why you've done this. Why is a submit button only
                        > available in no-js situations?
                        >[color=green]
                        > > snide, smartass, unhelpful comments are useless. Please keep them
                        > > to yourself.[/color]
                        >
                        >
                        > Best not to cop an attitude, especially before you've gotten any help.[/color]

                        absolutely right.

                        Comment

                        • cruiserweight

                          #13
                          Re: best-practice form checking

                          Steve Pugh <steve@pugh.net > wrote in message news:<u2umb050p rvekh4a6acj8dbi 1mmk08vd9b@4ax. com>...[color=blue]
                          > bayon86@yahoo.c om (cruiserweight) wrote:
                          >[color=green]
                          > >I've constructed this form so that if Javascript is disaabled it will
                          > >show a typical <input type="submit"> button, BUT using the <noscript>
                          > >tag.[/color]
                          >
                          > What happens for users who do have JavaScript enabled? Do they get a
                          > submit button at all?
                          >
                          > In what way does it benefit some users _not_ to have an instantly
                          > recognisable submit button?[/color]

                          I believe this is the correct question. It benefits no one for 'some
                          users _not_ to have an instantly recognisable submit button'.

                          However, I'd really like to get away from, or at least explore,
                          options to the standard UI available through html. Overindulgent?
                          Perhaps a little. In this case, though, I will rework it to use the
                          onsubmit event handler as suggested and go with the admittedly
                          unnecessary javascript button.

                          Comment

                          Working...