Solved

VALIDATE A HTML SELECT

Posted on 2000-04-06
3
168 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

920 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

16 Experts available now in Live!

Get 1:1 Help Now