Onsubmit continues after return false

Hi, I have something really weird going on.

In this form header:

<% form_for(:task,:url => tasks_path, :html => { :onsubmit =>
‘validate_task();’, :id => “new_task” }) do |f| %>

I call “validate_task” to validate some of the form inputs. The
javascript returns false when I don’t fill in the task name. Simple,
right. What’s weird is that the form submit continues even though the
javascript returns false. Why is this?

I’ve tried to work around this. If I have the onsubmit return false,
the form doesn’t get submitted. But when I have a function call return
false, the form still submits through. The validate function is in
application.js.

Any help you can give would be greatly appreciated!

Mike

On 10 Nov 2007, at 18:32, Mike D. wrote:

right. What’s weird is that the form submit continues even though the
javascript returns false. Why is this?

You actually have to say return foo - this isn’t like ruby, ie your
onsubmit should be ‘return validate_task();’

Fred