Form validation issue in form_remote_tag

R

Ruby Quest

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;
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,130
Latest member
MitchellTe
Top