Form validation issue in form_remote_tag

R

Ruby Quest

In one of my application part, I am validating 'not null' check of
particular field of my form before submitting the form. The javascript
function 'validateTitle' does it correctly. but what my problem is the
form page gets reloaded and there is nothing on the page EXCEPT response
string in the "Respbox" div. I want to retain the form fields as it is,
after submitting form.

what is the problem in my code???? any help is appreciated..


------My form tag is simillar to below code--------


<div id="Respbox" style="align:center"></div>

<%= form_remote_tag :url => { :action => 'create' },:before => 'return
validateTitle()' ,:update => 'Respdiv' %>

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

<%= submit_tag "Add " %>

<%= end_form_tag %>




--------My Javascript code -----------------

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
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top