Wednesday, October 14, 2009

Java Script Validations in RESTful Ruby on Rails Form

We can validate ruby on rails form using java script.It is show in bellow example

java script function

function validate()
{
//validation code
if (valid)
return true
else
return false
}

ruby on rails form

<% form_for(@patient_details,:html=>{:onsubmit=>"return validate();"}) do |f| %>
<%= f.error_messages %>
#form

<%end%>

No comments:

Post a Comment