Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How can I force a user to selet yes or no from a drop down list and not leave it as "choose one"?

Posted on 2007-11-20
4
178 Views
Last Modified: 2010-08-05
On our page there are a few drop down lists that are set at "Choose One" by default.  How can I make it so that they HAVE to select yes or no?  This has become a problem as users are not supplying us with enough information so we have to do this now...  I have pasted the part of code we need this in...  Thank you!
<tr><td>Number of Licenses: </td>
<td>
 
<input tabindex=7 type="text" name="requiredLicenseNumber" size="2" maxLength=2 style="width: 22px"></td>
</tr>
 
<tr><td>Site License: </td>
<td><SELECT tabindex=8 size=1 name=requiredSiteLicense> <OPTION selected>Choose</OPTION><OPTION>Yes</OPTION>
	<OPTION>No</OPTION></SELECT></td>
</tr>
 
<tr><td>Network License: </td>
<td><SELECT tabindex=9 size=1 name=requiredNetworkLicense> <OPTION selected>Choose</OPTION><OPTION>Yes</OPTION> 
        <OPTION>No</OPTION></SELECT></td>
</tr>
 
<tr><td>Software Users: </td>
<td>
<input tabindex=10 type="text" name="requiredSoftwareUsers" size="30"></td>

Open in new window

0
Comment
Question by:Jscott82305
  • 2
4 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20319453
you can remove the "choose" option i think that would be easiest to go, then the user HAS to choose YES or NO.

Another way is to use radio buttons, YES and NO, so the user has to choose 1 radio button.

hope that helps.
0
 
LVL 9

Accepted Solution

by:
brunoguimaraes earned 500 total points
ID: 20319529
Try the code below. Then use a JavaScript function on the submit button to test if the option value equals blank.

Something like:

function onSubmit() {
        if (document.getElementById('requiredSiteLicense').value == '') {
                alert('Choose an option');
                return false;
        }
        return true;
}
<tr><td>Site License: </td>
<td><SELECT tabindex=8 size=1 name=requiredSiteLicense> <OPTION selected value="">Choose</OPTION><OPTION value="Y">Yes</OPTION>
        <OPTION value="N">No</OPTION></SELECT></td>
</tr>

Open in new window

0
 

Author Comment

by:Jscott82305
ID: 20320177
Thanks a lot!  I will give this a try and keep you posted! I appreciate the fast response!!
0
 

Author Closing Comment

by:Jscott82305
ID: 31410109
Thank you
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question