473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

121 100+
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
1 1452
PreethiGowri
126 64KB
check this out "ItemEvent.SELECTED"
Feb 25 '13 #2

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

Similar topics

2
by: Serge Myrand | last post by:
Hi, I cannot get the selected option to be POSTed (it does not appear in the QueryString when using GET neither) I construct the drop down list from an array, I select an element in the list,...
1
by: ouioui | last post by:
Hi, I try to have a communicatition between 2 windows In the first one i have a HTML styled select like that : <form name='addform' id='addform' action='add_dossier.php' method='post' >...
4
by: Mark Kolber | last post by:
I did a little searching on this but couldn't find an answer... On my website, I have a section of stories (www.midlifeflight.com/stories) There are different stores on different pages that are...
8
by: McKirahan | last post by:
Firefox does not reflect selected option via innerHTML How do I get Firefox to reflect selected option values? <html> <head> <title>FFinner.htm</title> <script type="text/javascript">...
0
by: Robert | last post by:
Stephen, I think I figured out the problem. I was able to get Check Boxes and Option Buttons to work on my form by TURNING OFF RECORD SELECTORS on the form. Not sure why this would make a...
6
by: Chameleon | last post by:
In the code below I want to alert the selected option of select. In Mozilla the code works (If I choose "3" alerts it). In IE alerts: nothing appear --------------------- <script> function hi()...
7
by: brendan.wong | last post by:
hello. i have a really simple form that asks the user to select a Month from a dropdown. the first time a user visits the page, the highlighted option should be October, which works fine. then,...
11
by: woodey2002 | last post by:
This problem is driving me crazy. Hello there, i am trying to create a search form for records in my access database. The search form will contain text boxes and a multi select list box. The user...
6
by: chanshaw | last post by:
Hi I'm trying to get the text from the selected <option> of a <select> function loadSelectQuestion() { var dropdownIndex = document.getElementById('selectCategory').value;...
10
by: puT3 | last post by:
I want to get the value from Product_Price field which it will display it record on a text box based on a product that is selected from a list box. Product Table Product_ID Product_Name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.