Drop Down List Validation Not Working
<p>I am trying to validate the drop downlist using jquery .But It is not Working. I am not much familiar on javascript. I have added My html and validation code. Please Check that for more information.other functions are working perfectly. only I need to validate the drop down list.</p>

<pre><code>&lt;li class="form-row"&gt;&lt;label&gt;Department Head:&lt;/label&gt;
                    &lt;select name="departmentHead" class="text-input required" id="myDropdown"style="width: 158px"&gt; &lt;option value="0"&gt;Select Department Head&lt;/option&gt;
                        &lt;%

                            String val = "";
                            Department dp = new Department();
                            ResultSet rs = dp.addHeadOfDepartment();
                            while (rs.next()) {
                                val = rs.getString(2);
                        %&gt;

                        &lt;option value="&lt;%= val%&gt;"&gt;&lt;%= val%&gt;&lt;/option&gt;
                        &lt;%
                            }

                        %&gt;


                    &lt;/select&gt;
                &lt;/li&gt;
</code></pre>

<hr>

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

        $('.btn-submit').click(function(e){

            // Declare the function variables:
            // Parent form, form URL, email regex and the error HTML
            var $formId = $(this).parents('form');
            var formAction = $formId.attr('action');
            var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
            var $error = $('&lt;span class="error"&gt;&lt;/span&gt;');

            // Prepare the form for validation - remove previous errors
            $('li',$formId).removeClass('error');
            $('span.error').remove();

            // Validate all inputs with the class "required"
            $('.required',$formId).each(function(){
                var inputVal = $(this).val();
                var $parentTag = $(this).parent();
                if(inputVal == ''){
                    $parentTag.addClass('error').append($error.clone().text('Required Field'));
                }




 if ($('#myDropdown').val() == "") {
        alert("Please select anyone");
        e.preventDefault();
        return false;
    }



                // Run the email validation using the regex for those input items also having class "email"
                if($(this).hasClass('email') == true){
                    if(!emailReg.test(inputVal)){
                        $parentTag.addClass('error').append($error.clone().text('Enter valid email'));
                    }
                }

                // Check passwords match for inputs with class "password"
                if($(this).hasClass('password') == true){
                    var password1 = $('#password-1').val();
                    var password2 = $('#password-2').val();
                    if(password1 != password2){
                        $parentTag.addClass('error').append($error.clone().text('Passwords must match'));
                    }
                }
            });

            // All validation complete - Check if any errors exist
            // If has errors
            if ($('span.error').length &gt; 0) {

                $('span.error').each(function(){

                    // Set the distance for the error animation
                    var distance = 5;

                    // Get the error dimensions
                    var width = $(this).outerWidth();

                    // Calculate starting position
                    var start = width + distance;

                    // Set the initial CSS
                    $(this).show().css({
                        display: 'block',
                        opacity: 0,
                        right: -start+'px'
                    })
                    // Animate the error message
                    .animate({
                        right: -width+'px',
                        opacity: 1
                    }, 'slow');

                });
            } else {
                $formId.submit();
            }
            // Prevent form submission
            e.preventDefault();
        });

        // Fade out error message when input field gains focus
        $('.required').focus(function(){
            var $parent = $(this).parent();
            $parent.removeClass('error');
            $('span.error',$parent).fadeOut();
        });
    });
</code></pre>
