Form validation issue in form_remote_tag

In one of my application, I am using form validation check for
particular form field before submitting the form. The javascript
validation method “validateTitle()” does it work properly. But what my
problem is, the page gets reloaded after submitting the form and there
is nothing on the page EXCEPT response message in the “Respbox” div.

I want to retain my form as it is, after submitting the form(Of course,
with response message).

What is the problem in my code??? Any help is appreciated…

---------My form is simillar to this-----------

<%= form_remote_tag :url => { :action => ‘create’ },:before => ‘return
validateTitle()’ ,:update => ‘Respbox’ %>

---------my form fields go here------------

<%= submit_tag “Add” %>

<%= end_form_tag %>

-----------My javascript function--------------
function validateTitle()
{

var title = document.getElementById(“item_title”).value
if(title.length == 0 )
{
alert(“Item Title cannot be empty”);
return false;
}

}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs