i want to validate that a selection is made when the form is submitted. the tricky part is i also have an option where the user can add more rows so that they can insert more than 1 record at a time. how do i get the js to validate?
this is my html and js notice the name of the select is 'cid[]'
Code:<td bgcolor="#666666"><SELECT name='cid[]' class="one_pixel_border"> <option selected value="">Select One</option> <? $cQuery = mysql_query("SELECT cid, category FROM category"); while ($sRow = mysql_fetch_row($cQuery)) { print ("<OPTION value='$sRow[0]'>$sRow[1]</OPTION>"); } ?> </SELECT> </td> <script language="javascript1.2" type="text/javascript"> function valbutton(thisform) { if (thisform.cid.selectedIndex < 1) { alert("Please select a category."); thisform.cid.focus(); return false; } } </script>




Bookmarks