Event.stop(e) does indeed prevent event propagation.  I would assume
that your code is hitting an exception before Event.stop is being
executed.

> Try calling Event.stop() at the very beginning of the script, before
> anything else, then if there are no errors, call event.form.submit()
> to carry on with the original submit event.

@Walter: If you have a submit handler that executes the object's
submit event wouldn't this lead to an infinite loop?
Wouldn't the idea be, catch the submit event, validate the fields, if
all is valid, allow the event to proceed, if its not then stop the
event.

function handleLoad(){

   $("myForm").observe("submit", function(e){

   var invalidArr = $("myForm").select("input.req, textarea.req,
select.req").findAll(function(element){ return element.value != "" });
   if(invalidArr.length > 0){
        e.stop(); //prototype 1.6 code to event stop.
        handleInvalids(invalidArr )
   }
});

}

Event.observe(window, "load", handleLoad);


--

http://positionabsolute.net

On Mar 18, 11:59 am, Walter Lee Davis <wa...@wdstudio.com> wrote:
> Try calling Event.stop() at the very beginning of the script, before  
> anything else, then if there are no errors, call event.form.submit()  
> to carry on with the original submit event.
>
> Walter
>
> On Mar 18, 2009, at 11:45 AM, Alex Mcauley wrote:
>
>
>
> > It still does not work with "Event.stop(event);" for some reason ....
>
> > i even tried changing the code to .....
>
> > var error='';
> > $$('.req').each(function(e) {
>
> >   if($(e).value=='') {
> >    error+='Required';
>
> > }
>
> > });
> > if(error.length>=1) {
> >  alert(error)
> >  Event.stop(event); // does not work
>
> > }
>
> > ----- Original Message -----
> > From: "Alex Mcauley" <webmas...@thecarmarketplace.com>
> > To: <prototype-scriptaculous@googlegroups.com>
> > Sent: Wednesday, March 18, 2009 3:42 PM
> > Subject: [Proto-Scripty] Re: Stopping events ..
>
> >> Doh !!!!!! i knew it was something simple !!
>
> >> Thanks
> >> Alex
> >> ----- Original Message -----
> >> From: "Walter Lee Davis" <wa...@wdstudio.com>
> >> To: <prototype-scriptaculous@googlegroups.com>
> >> Sent: Wednesday, March 18, 2009 3:11 PM
> >> Subject: [Proto-Scripty] Re: Stopping events ..
>
> >>> Has to be capital E event:
>
> >>> Event.stop(event)
>
> >>> Walter
>
> >>> On Mar 18, 2009, at 10:40 AM, Jeztah wrote:
>
> >>>> event.stop(event); // doesnt stop the request from firing
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to