how to check if a selection field is selected
<p>i have a selection field and when the button #btnaddtocart is selected i want to be able to check if the selection (name=quantity) isnt null, if it is then an alert is shown to the user. otherwise not to show anything. the script works but the problem is that if the selection does contain a value the alert still shows. why is this?</p>

<p>here is the html</p>

<pre><code>&lt;select class="select" id="quantity" name="quantity"&gt;
&lt;option selected="selected" value=""&gt;select one&lt;/option&gt;
&lt;option value="data1"&gt;data1&lt;/option&gt;
&lt;option value="data2"&gt;data2&lt;/option&gt;
&lt;option value="data3"&gt;data3&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>here is the js </p>

<pre><code>$(document).ready(function() {

    $("#btnaddcart").click(function()
    {

         if($("input[name=quantity]").val() == null)
          {
               var data = $(this).val();
               alert(data);
          }
      });
});
</code></pre>
