• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

VALIDATE A HTML SELECT

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
jonnygrant
Asked:
jonnygrant
1 Solution
 
DeatheadCommented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now