I am using form for here is my code
new.html.erb
<h1>New animal</h1>
<% form_for(@animal) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :desc %><br />
<%= f.text_field :desc %>
</p>
<p>
<%= f.submit 'Create', :onClick => 'new_animal();' %>
</p>
<% end %>
<%= link_to 'Back', animals_path %>
main.js
function new_animal(){
alert('animal');
if(document.getElementById('animal_name').value=="")
{
alert("Enter name...");
document.getElementById('animal_name').focus();
return false;
}
if(document.getElementById('animal_desc').value=="")
{
alert("Enter animal description ...");
document.getElementById('animal_desc').focus();
return false;
}
}
i got message that animal then i preesed ok form redirt to index page
and insert record in db.
--
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
-~----------~----~----~----~------~----~------~--~---