<input onclick=validate not working?

it is not validating the amt1 input box?
Any idea why?


<script language="JavaScript" type="text/javascript">
            <!--
            function validate()
            {
                    if(document.test4.Amt1.value == '0')
                        {
                          alert('Please enter donation amount greater than $0');
                         document.test.Amt1.focus();
                        return false;
                        }
                  document.test4.submit();
            }
            //-->
            </script>

<form name="test4" style="color: #000080;" action="submit.asp" method="get">
<table style="width: 400px; height: 150px">
<tr><td colspan="2"></td></tr>
<tr><td>Program</td><td>
<select name="programURL">
<option value="">Select Program </option>
</select>
</td></tr>
<tr><td>Amount</td><td><input name="Amt1" size="8" maxlength="8" style="width: 70px; height: 20px;" class="style9" value="0"/></td></td></tr>
<tr><td colspan="2">
<input type="image" src="Donate.gif" border="0" name="submit" width="92" height="26" class="style5" onclick="javascript:validate();">

            
</td></tr></table>

</form>
dkim18Asked:
Who is Participating?
 
Dave BaldwinConnect With a Mentor Fixer of ProblemsCommented:
You probably need to put it in your form tag like this:

<form name="test4" style="color: #000080;" action="submit.asp" method="get" onsubmit="return validate();">
0
 
Wayne BarronConnect With a Mentor Author, Web DeveloperCommented:
Why don't you use Server Side validation instead of JavaScript.

In this case, you could do something like this.

This will go on the process page.
<%
Amt1 = request.form("Amt1")
if Amt1=0 then
response.write"Please enter donation amount greater than $0"
else
' do what you need to do here.
end if
%>

Carrzkiss
0
 
H_D_AConnect With a Mentor Commented:
what browser did you use for testing?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.