# Problem --\> "onsubmit" in "remote\_form\_for"?

**URL:** <https://www.ruby-forum.com/t/problem-onsubmit-in-remote-form-for/157803>\
**Category:** Ruby\
**Created:** [January 15, 2009, 2:01pm UTC](https://www.ruby-forum.com/t/problem-onsubmit-in-remote-form-for/157803 "2009-01-15T14:01:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac91a4/32.png) [@vikas](https://www.ruby-forum.com/u/vikas)\
**Post date:** [January 15, 2009, 2:01pm UTC](https://www.ruby-forum.com/t/problem-onsubmit-in-remote-form-for/157803/1 "2009-01-15T14:01:52Z")

</div>

I want to check whether textfield is empty or not at onsubmit event of  
form, but it is not working.  
Can any one tell me how to check empty textfield on remote\_form\_for’s  
onsubmit event???

my code is ---------------\>

\<%remote\_form\_for(:comments, @comment, :url =\> @commentUrl, :html =\>  
{:method =\> :post, :onsubmit =\> ‘if ($(“comments\_comment”).value == “”)  
{showNotificationMessage(“Please enter comment”, Notification.Error,  
comments\_comment); return false;}’}) do |f| %\>  
\<%= f.text\_area “comment”, :rows =\> 2,  
:style=\>“width:100%;padding-right:8px;margin-top:8px;margin-bottom:8px;”  
%\>

```
  <%=submit_to_remote f, "Add comment",
    :url => @commentUrl,
    :update => { :success => divID, :failure => divID }%>
<%end%>
```

---

<div class="post-metadata">

**Author:** ![vikas](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ac91a4/32.png) [@vikas](https://www.ruby-forum.com/u/vikas)\
**Post date:** [January 15, 2009, 2:25pm UTC](https://www.ruby-forum.com/t/problem-onsubmit-in-remote-form-for/157803/2 "2009-01-15T14:25:50Z")

</div>

Vikas G. wrote:

> I want to check whether textfield is empty or not at onsubmit event of  
> form, but it is not working.

Sorry, but you’ve stumbled onto the wrong mailing list. This list is for  
the Ruby programming language; there are some Rails people here, but you  
are more likely to find the answers you need on a mailing list for the  
Rails framework (which just happens to be written in Ruby)
