# Problem with javascript validation in rails

**URL:** <https://www.ruby-forum.com/t/problem-with-javascript-validation-in-rails/141754>\
**Category:** Rails\
**Created:** [June 30, 2008, 12:32pm UTC](https://www.ruby-forum.com/t/problem-with-javascript-validation-in-rails/141754 "2008-06-30T12:32:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![supriyaiiita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9adbd/32.png) [@supriyaiiita](https://www.ruby-forum.com/u/supriyaiiita)\
**Post date:** [June 30, 2008, 12:32pm UTC](https://www.ruby-forum.com/t/problem-with-javascript-validation-in-rails/141754/1 "2008-06-30T12:32:08Z")

</div>

Hi all,

I have a form for adding new entries in my “dev” model.  
I need to check empty fields in that using javascript function. but in  
my  
form im having combo box and other fields in rails code.

my query is : does javascript function identify rails code and validate  
the  
fields like it does for html?

my code is given below… but it doesnt work… please help me with this:

view:

### Add Device
 

\<%= "Fields marked with \* are required" %\>

Device Info
1. Device Name : \<%= text\_field "dev", "name", :size =\> 20%\> \<%= "\*" %\>

Location Details
1. Lab : \<%= collection\_select(:labt, :id, @labts, :id, :name,:prompt=\>"Select a Lab") %\>\<%="\*"%\> 

javascript function:

–  
View this message in context:  
[http://www.nabble.com/Problem-with-javascript-validation-in-rails-tp18192684p18192684.html](http://www.nabble.com/Problem-with-javascript-validation-in-rails-tp18192684p18192684.html)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).
