Help with Javascript code

I have a DDL with “other” as an option. If Other is selected the textbox appears. If someone tries to submit the form I want an error message to appear.

What am I doing wrong or is there another way to do this?

<html xmlns=“http://www.w3.org/1999/xhtml” >
<head runat=“server”>
<style type=“text/css”>
.hidden {
display: none;
}
</style>
<title>Untitled Page</title>
<script type=“text/javascript”>

function enableOther()
{
if (!document.getElementById) return;
var s = document.getElementById(‘reason1’);
if (!s) return;
if (s.options[s.selectedIndex].value != 'Other: ') return;
var t = document.getElementById(‘reason1other’);
if (!t) return;
t.disabled = false;
t.className = ‘’;
}

function init()
{
if (!document.getElementById) return;
var s = document.getElementById(‘reason1’);
if (!s) return;
s.onchange = enableOther;
var t = document.getElementById(‘reason1other’);
if (!t) return;
t.disabled = true;
t.className = ‘hidden’;
}

window.onload = init;
</script>

</head>
<body>
<form id=“form1” runat=“server”>
<div>
<form>
<select id=“reason1” name=“reason1”>
<option value=“P.T.”>P.T.</option>
<option value=“Break”>Break</option>
<option value=“IT”>IT Issues</option>
<option value=“Training”>Training</option>
<option value=“Briefing”>Briefing</option>
<option value=“Supervisor”>Supervisor</option>
<option value="Other: ">Other</option>
</select>
<input type=“text” id=“reason1other” name=“reason1other” Size=22 />
</form>
</div>
<asp:Button ID=“Button1” runat=“server” Text=“Button” OnClientClick=“enableOther();” />
</form>
</body>
</html>

Thanks!

Just to rule out an obvious problem, can you show us what the ASP code looks like as HTML code, once it’s been given to the web browser?

I’m sorry I don’t know what you mean.

Do you mean to make the page an html page with a dropdown box?

Here is what I mean. The cause for your problem is not obvious, and some of us do not have an environment that can compile ASP code. Since JavaScript works only with the HTML code that is given to the web browser, you will receive the best help if you can provide a sample test page that demonstrates the problem, because then we can load it up locally, play around with it, and work out what is going wrong for you.

If you cannot provide a link to a test page that demonstrates the problem, the next best thing you can do is to provide HTML code that can allow us to experience the same problem that you’re having.

Something that you may first want to investigate though, is that forms must not be nested within each other. That’s just not allowed.

okay I understand. I need this to work with aspx code as the entire page is set up that way. I thought what I sent was ample enough to be placed into an html page and it will come up as to what I have on my page. I took the code and placed it in an html page and it came up.

Thanks don’t worry about it I will try to get the customvalidator to work in asp.net. Thanks anyway.