By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,650 Members | 1,368 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,650 IT Pros & Developers. It's quick & easy.

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

100+
P: 121
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)
Expand|Select|Wrap|Line Numbers
  1. 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

Expand|Select|Wrap|Line Numbers
  1.  if ($("#DivId option:selected").val().length == 0);
  2.  {
  3.      alert('please choose dropdown 2');
  4.       return false;
  5.  }
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
Feb 11 '13 #1
Share this Question
Share on Google+
1 Reply


100+
P: 126
check this out "ItemEvent.SELECTED"
Feb 25 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.