dialog form dropdown validation

dialog form dropdown validation

 Hi all,

I am trying to modify modal form example from http://jqueryui.com/demos/dialog/
so it would check for drop down selection.


I've added

                function checkSelect(n,p) {

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







                }

and all needed variables for that form field.  But drop down selection
check is not working. No errors just submits the form.  I've tried
using the full document.form.field or getElementById and it just tells
me it's not defined.
(p.length < 5) by itself works fine so I know it's calling that
funtion
Anyone has any ideas?