Onsubmit for remote_form_for not working properly

I want to use onsubmit for a form validation using javascript on
remote_form_for

for this i am doing something like this

<% remote_form_for :timesheet, @timesheet, :url =>{:action =>
‘report_user’}, :html => {:onsubmit=>“return ValidateDate();” } do |f|
%>

// Form elements here

<% end %>

but it not works well. if condition return false then my form is not get
submitted this is exactly what i want but when it returns true it
produce something like this o/p on UI.

Element.update(“user_report”, "\n\n\u003Ctable class=“list
issues”\u003E\n \u003Cthead\u003E\u003Ctr\u003E\n
\u003Cth\u003E#\u003C/th\u003E\n

when i delete :html code it works fine.

Regards,
Salil

<% remote_form_for :timesheet, @timesheet, :url =>{:action =>
‘report_user’}, :html => {:onsubmit=>“return ValidateDate();” } do |f|
%>

I guess this is a JavaScript issue. What about showing us that?

Thanx 4 ur reply

No i am just telling what problem i m facing.
i just want to know is onsubmit working properly with remote_form_for?
and wheather there is any syntax error in my code above ?

Regards,
Salil

On 10 Mar., 06:20, Salil G. [email protected]
wrote:

I want to use onsubmit for a form validation using javascript on
remote_form_for

but it not works well. if condition return false then my form is not get
submitted this is exactly what i want but when it returns true it
produce something like this o/p on UI.

Element.update(“user_report”, "\n\n\u003Ctable class="list
issues"\u003E\n \u003Cthead\u003E\u003Ctr\u003E\n
\u003Cth\u003E#\u003C/th\u003E\n

I guess this is a JavaScript issue. What about showing us that?

On 10 Mar., 08:29, Salil G. [email protected]
wrote:

<% remote_form_for :timesheet, @timesheet, :url =>{:action =>
‘report_user’}, :html => {:onsubmit=>“return ValidateDate();” } do |f|
%>
I guess this is a JavaScript issue. What about showing us that?

Thanx 4 ur reply

No i am just telling what problem i m facing.
i just want to know is onsubmit working properly with remote_form_for?
and wheather there is any syntax error in my code above ?

No, remote_form_for will use the onsubmit event to make the actual
AJAX request. So I don’t think overriding the onsubmit attribute would
be a good idea… :slight_smile:


Cheers,
David K.
http://twitter.com/rubyguy

On Mar 17, 4:17 pm, Salil G. [email protected]
wrote:

No, remote_form_for will use the onsubmit event to make the actual
AJAX request. So I don’t think overriding the onsubmit attribute would
be a good idea… :slight_smile:

thanx @David.
Do you know what should do in that case to put javascript form
validations?

The ajax helpers can take a :conditions parameter which is a fragment
of javascript to run to check whether the request should go ahead
(it’s described in the docs for link_to_remote)

Fred

No, remote_form_for will use the onsubmit event to make the actual
AJAX request. So I don’t think overriding the onsubmit attribute would
be a good idea… :slight_smile:

thanx @David.
Do you know what should do in that case to put javascript form
validations?

Thanx & Regards
Salil