Try it this way:
Event.observe('form', 'submit', function (evt) { // Added function param
Event.stop(evt); // Stop propogation;
return (
check_first_name() && check_last_name() &&
check_username() && check_password() && check_password_confirm()
);
});
Returning false only works if the function is directly set as the
event handler, rather than being attached/observed (i.e. $
('form').onsubmit = function() {return false;}, although using
Event.stop() is not in appropriate in this instance, although you'd
also need to bindAsEventListener() or implement some other cross-
browser method of getting the event.
I hope my ramblings make sense.
TAG
[EMAIL PROTECTED]
On Feb 7, 2007, at 2:39 PM, Matt Alexander wrote:
>
> I have the following code that I'm using to validate the form:
>
> Event.observe('form', 'submit', function () {
> return (
> check_first_name() && check_last_name() &&
> check_username() && check_password() && check_password_confirm()
> );
> });
>
> How do stop the form from submitting if I return false?
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---