Solved

VALIDATE A HTML SELECT

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

856 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