# How to use onsubmit in remote\_form\_for.....?

**URL:** <https://www.ruby-forum.com/t/how-to-use-onsubmit-in-remote-form-for/157872>\
**Category:** Rails I18n\
**Created:** [January 16, 2009, 6:09am UTC](https://www.ruby-forum.com/t/how-to-use-onsubmit-in-remote-form-for/157872 "2009-01-16T06:09:21Z")\
**Posts on this page:** 1\
**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 16, 2009, 6:09am UTC](https://www.ruby-forum.com/t/how-to-use-onsubmit-in-remote-form-for/157872/1 "2009-01-16T06:09:21Z")

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

```

‘onsubmit’ is not excuted during form submit.  
Any one can help me.
