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>
-- 
View this message in context:
http://www.nabble.com/Problem-with-javascript-validation-in-rails-tp18192684p18192684.html
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---