Problem with disable_with


#1

Hi Group,

I have a registration.html.erb page with the following JavaScript at
the top which I use to validate form fields:

further down the page I have the form:

<% form_tag({:action => ‘sendregistration’}, {:name =>
“myForm”, :onSubmit => “return validate()”}) do -%>

Project Name: * <%= text_field 'email', 'projectname', :size => 30 %> Project Type: * <%= collection_select 'email', 'projecttype_id', @projecttypes, :id, :name, { :include_blank => true } %> Region: * <%= collection_select 'email', 'region_id', @regions, :id, :name, { :include_blank => true } %>

etc.

<%= submit_tag “Send”, :class => “submit”, :id =>
“mysubmit”, :disable_with => “Please wait…” %>

<% end -%>

When I click ‘Send’ without the required fields the ‘Send’ button is
disabled and the text is replaced with ‘Please wait…’ which is as I
expected. It also performs the ‘validate’ JavaScript function and
discovers that the required fields are not provided and displays a
popup window with the text ‘You must fill in all of the required
fields!’

When I click ‘Send’ with the required fields the ‘Send’ button is
disabled and the text is replaced with ‘Please wait…’ which again is
as I expected. However, the form does not Submit / Post, it just
hangs.

What am I doing wrong? Would someone please help.

Thanks.

Regards

Walter


#2

You can always return false and inside the else block, add this
javascript that will submit the form:
document.forms[“myForm”].submit();


#3

Hi Klaus,

thanks for your response. I tried this:

which I hope is what you were proposing in your response, but it still
doesn’t Post. It just hangs.

Regards

Walter


#4

Hi Klaus,

thanks for your help. The following code now works:

Thanks again.

Regards

Walter


#5

Hi Klaus,

now I’m really confused. When I remove the validation and use return
true:

It posts, no problem.

Any ideas?

Regards

Walter