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:

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

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

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

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

</ol>
</fieldset>

<fieldset class="submit">

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

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

} </script>