How can i check if user has selected any option from dropdown

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jay123
    New Member
    • Sep 2008
    • 121

    How can i check if user has selected any option from dropdown

    Hello,

    As title states, i have a DropdDown and i need to stop user submitting form if he hasn't selected anything in Dropdown

    i am using (for testing purpose)
    Code:
    alert($("#DivId option:selected").val().length);
    and it return 0 if nothing selected and length of selected option (if selected), but when i use same command in If like

    Code:
     if ($("#DivId option:selected").val().length == 0);
     {
         alert('please choose dropdown 2');
          return false;
     }
    this always shows the alert message irrespective of if user has selected anything in Dropdown or not. but first alert shows correct value.

    Can somebody please help me where i am going wrong, Its something very minor and frustating.

    Any help will be appreciated.

    Regards
  • PreethiGowri
    New Member
    • Oct 2012
    • 126

    #2
    check this out "ItemEvent.SELEC TED"

    Comment

    Working...