Solved

VALIDATE A HTML SELECT

Posted on 2000-04-06
1
197 Views
Last Modified: 2010-04-09
this is my code:

<Font type="verdana" size="2">Urgency:</Font><SELECT size=1 id=txtUrgency_Type name="txtUrgency_Type">
<OPTION selected>Please select</OPTION>
<OPTION value="URG">Urgent</OPTION>
<OPTION value="NON">Non Urgent</OPTION>
</SELECT>

i want to validate this in jscript any ideas?

also how do i pass this value to an asp page
0
Comment
Question by:jonnygrant
1 Comment
 

Accepted Solution

by:
Deathead earned 20 total points
ID: 2689771
in between the <head></head> tags place the following code

<script language="Javascript">
function ckit()
{
  if(document.forms['FORMNAMEHERE'].elements['SELECTNAMEHERE'].selectedIndex == 0)
  {
   alert("Please choose Urgent or Non urgent")
   return false
  }
  else
  {
    return true
  }
}
</script>

and in your <form> tag place the command onSubmit='return ckit()'
it should look like this
<form Action="WHATEVER" name="FORMNAME" onSubmit="return ckit()">

you will need to add names to the form tag and select tag as javascript does not handle the ID tag good in both browsers
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

825 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