Solved

VALIDATE A HTML SELECT

Posted on 2000-04-06
3
157 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
  • 2
3 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 2689818
<SCRIPT language='javascript'>
function validateUrgenceyType(theSelect)
{
   if ( theSelect.selectedIndex <= 0 )
   {
       alert("Please select a value for Urgency.");
       theSelect.focus();
       return(false);
    }
    return(true);
}
</script>


Call the above function in your form's onSubmit:

<FORM .... onSubmit='return(validateUrgenceyType(this.txtUrgency_Type));'>
0
 
LVL 11

Accepted Solution

by:
thunderchicken earned 20 total points
ID: 2690005
In asp you'd use this

<%
dim lastVal
lastVal = Request.form("txtUrgency_Type")

if lastVal = "URG" then
   response.write("Urgent")
else
   response.write("Non Urgent")
end if
%>

but you have to make sure it's within the <form> tags

0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2690705
>> i want to validate this in jscript any ideas?

I don't want to raise a stink over a measly 20 points, but why did you accept a VB script answer when what you asked for was a jscript answer?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now