Dialog - drop-down validation

Dialog - drop-down validation

I am trying to validate drop-down & text field where one of them has to have value but I can't get the drop-down validation to work.  I am not getting any errors it just ignores validation for drop-down. Here us my code:

  1. function checkSelect(n,p) {        

                if ( (selcategory.selectedIndex == 0) && (category.value == '')) {
                    p.addClass('ui-state-error');
                    updateTips("You must either type in or select category");
                    return false;
                } else {
                    return true;
                }

            }