Problem with javascript validation in rails

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:

<form action="/device/addDevice" method="post" onsubmit="return
validate(document.getElementById('labt_id'),'Choose!')" name="validation">

  Add Device</h3><fieldset> <p style="color:red;"> <%= "Fields marked with
* are required" %></p>
<legend>Device Info</legend>

  <label>Device Name </label>:
  <%= text_field "dev", "name", :size => 20%> <style="color:red;"><%= "*"

<fieldset><legend class="style5">Location Details</legend>
<li><label>Lab : </label>
<%= collection_select(:labt, :id,
                         @labts, :id, :name,:prompt=>"Select a Lab")
%><%="*"%> </li>


<fieldset class="submit">

<input name="commit" type="submit" value="Add Device" />

javascript function:
<script type="text/javascript">
function validate(elem,msg) {
if(elem.value=="Select a Lab")
return false;
return true;

} </script>