[thelist] dHTML Form Elements && tip re: Disabling the <enter> key to submit a form.

Tab Alleman talleman at autobex.com
Fri Dec 1 12:14:57 CST 2000


(while you're tip addresses another list member's specific needs, i have a
great concern with the solution and it's far-reaching effects.)

<Tab>  Ah, true for you; I forgot to mention that I am currently working on
an Intranet where everyone will be using IE 5+
However, while I do agree with your first argument ("castrating" non-js
users), at the risk of displaying potential ignorance, I have qualms with 2
& 3:

(second, scripting these things makes it much more difficult to debug your
applications.  while it may be appealing to be able to post to two different
scripts the reality is that both scripts that take the form submission are
likely very similar.  rather than posting...)

<Tab>While this sounds reasonable, my real world experience hasn't shown
this to be the case.  I find it much easier to debug lots of small scripts
rather than a few big ones.  I think it becomes of matter of getting used to
doing things a certain way and developing a set of habits that helps you to
do them as efficiently as possible in whichever manner you've chosen.  In
other words, "It works for me.. Your Mileage May Vary"

(finally, relying on the submit() method makes it more difficult to validate
your form data prior to submission.  instead of being able to rely on the
onSubmit event handler for the form (which will not fire if the form is
submitted via the submit() method) you'll have to manually call the
validation routine...)

<Tab>How is this MORE difficult than using onsubmit?  You've already started
making a function that gets called when any of the "submit" buttons are
clicked, so what's so hard about putting the validation stuff at the
beginning of that function, and returning false if one of the tests doesn't
pass?  And secondly, if you're using client-side form validation, doesn't
that kind of invalidate your first argument about castrating the non-js
users?  or is onsubmit() something that will get seamlessly ignored by
non-js browsers?

(conclusion:  use of the submit() method is a kludge and not recommended.)

<Tab>I would temper this to a modest "Programmer Beware".  I think there are
times when it's at least safe, if not preferred, to use submit().. but
certainly we should all be mindful of the potential "gotchas" that you
pointed out.

Tab.






More information about the thelist mailing list