Jim Wooseman wrote:
> var theField = document.getElementById ('field1') ;
> theField.addEventListener ('change', validCk, false) ;
> }
> function validCk (e) {
> if (!/([a-c])/.test (this.value) ) {
> alert ('You must enter a, b, or c in this field.') ;
> e.preventDefault () ;
See
http://www.w3.org/TR/2000/REC-DOM-Le...ngs-htmlevents,
the change event is not cancelable so that preventDefault() does not help.
> More to the point, how can
> I ensure that the "submit" effects ARE canceled, and how can I do it
> when the actual page could have several dozen submit buttons, in guises
> such as...
If you want to cancel form submission by a submit button then you should
add an event listener for the submit event to the form itself. The
submit event can be cancelled so that listener should call
e.preventDefault() if you don't want the form to be submitted.
However note that calling the submit method of a form does not raise the
submit event.
--
Martin Honnen
http://JavaScript.FAQTs.com/