I had a better thought. How do I get the count of <select> options within a div? I can then loop thru the select options and see if any of them are value "0".
Is this possible? On May 11, 10:09 am, waseem sabjee <waseemsab...@gmail.com> wrote: > i suggest for this line > <option value="">Select something</option> > you assign the value of "0" > > in order to retrieve this value use the following js > <script> > $(function() { > > $("select").click(function() { > > var value = $(this).val(); > if(val != 0) { > // do what you need to do} else { > > alert("you have not selected an option"); > > } > }); > }); > > </script> > > On Mon, May 11, 2009 at 6:55 PM, Loony2nz <loony...@gmail.com> wrote: > > > I need some help with jquery's syntax for how to pop an error message > > when a select field is blank. > > > There's a form that uses the same css class for all of it's form > > fields. However, I would like to check to see if at least one section > > of the form is not "blank". > > > Here's my code: > > > <div id="schoolchoices"> > > <select name="9378_choice" class="schoolDropList"> > > <option value="">Select something</option> > > <option value="10">10</option> > > <option value="20">20</option> > > <option value="30">30</option> > > <option value="40">40</option> > > <option value="50">50</option> > > </select> > > <br /><br /> > > <select name="3483_choice" class="schoolDropList"> > > <option value="">Select something</option> > > <option value="10">10</option> > > <option value="20">20</option> > > <option value="30">30</option> > > <option value="40">40</option> > > <option value="50">50</option> > > </select> > > <br /><br /> > > <select name="2384_choice" class="schoolDropList"> > > <option value="">Select something</option> > > <option value="10">10</option> > > <option value="20">20</option> > > <option value="30">30</option> > > <option value="40">40</option> > > <option value="50">50</option> > > </select> > > </div> > > > I need to check to see if at least one of the above is not "blank". > > Here's the catch. The list of school choices is variable. It can be > > 1 school choice, it could be 4 school choices. But it's dynamically > > generated and I need to create a jquery js function that will validate > > at least 1 of the x school choices are chosen. The value of the > > select statement is dynamically generated to use the school's database > > ID. > > > There are other form elements to this sample code, but I only need > > this section of the form validated. > > > Thoughts on how to progress? > > > Thanks!