Solved

VALIDATE A HTML SELECT

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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

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…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

724 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