Hi there,
It's 1.47 am and I am kinda tired of searching for answers now. I hope
someone would respond.
I have a javascript to validate date and display error message. I also
have an ajax form that returns the value of the form provided the dates
are in the correct format.
I notice if I use submit_tag onclick, the form displays the error
message AND submits the form. On the other hand, if I use input
type="button," the form displays the error properly first without
submitting the form, but when it submits the form, it's no longer ajax
anymore (the result is displayed on a separate refreshed page).
My question: how to use submit_tag and prevents from submission if js
validation returns false?
<% form_remote_tag :update => 'practiceResult',
:loading =>
"$('indicator1').show()",
:complete =>
"$('indicator1').hide()",
:success =>
"set_blank('practice')",
:url =>
{:controller => 'profiles', :action => 'add_practice'} do %>
<div id='practiceForm'>
<%= render :partial =>
'profiles/practice_form', :objects => @profiles_practice %>
<%= hidden_field_tag 'practice_type',
'practice' %>
<div id="btn_practice" align="center">
<input type="button" name="commit"
value="Add practice" class="btnSubmit" onClick="validate_date(this.form,
this.form.practice_start_date.value,
this.form.practice_end_date.value);"
/>
</div>
<%= submit_tag "Add (ruby)",
:onclick=>"validate_date(this.form, this.form.practice_start_date.value,
this.form.practice_end_date.value);" %>
</div>
<% end %>
Thanks.
Milton
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" 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-talk?hl=en
-~----------~----~----~----~------~----~------~--~---