# Form validation issue in form\_remote\_tag

**URL:** <https://www.ruby-forum.com/t/form-validation-issue-in-form-remote-tag/83354>\
**Category:** Ruby\
**Created:** [January 25, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/form-validation-issue-in-form-remote-tag/83354 "2007-01-25T15:10:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubyquest](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/59ef9b/32.png) [@rubyquest](https://www.ruby-forum.com/u/rubyquest)\
**Post date:** [January 25, 2007, 3:10pm UTC](https://www.ruby-forum.com/t/form-validation-issue-in-form-remote-tag/83354/1 "2007-01-25T15:10:43Z")

</div>

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

\<%= 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;  
}

}
