Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VALIDATE A HTML SELECT

Posted on 2000-04-06
3
Medium Priority
?
211 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 60 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

610 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