So Ive been working really hard to get a working ASP captcha to incorporate into my form (note, classic ASP not .net).

I FINALLY got it working in a test area, the form looks like this:

<form action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post">   
   <table border="0" width="570" align="center" cellpadding="1" cellspacing="0">
				<tr> 
				    <td align="right" valign="center"><%=font4%><font color="#ff0000">*&nbsp;</font>First Name:&nbsp;</td>
				    <td align="left" valign="top"><input name="first" size="25" maxlength="50" tabindex="1"></td>
				  </tr>
				  <tr> 
				    <td align="right"><%=font4%><font color="#ff0000">*&nbsp;</font>Last Name:&nbsp;</font></td>
				    <td align="left"><input name="last" size="25" maxlength="50" tabindex="2"></td>
				  </tr>
				   <tr> 
				    <td align="right"><%=font4%>Company Name:&nbsp;</font></td>
				    <td align="left"><input name="company" size="25" maxlength="100" tabindex="3"></td>
				  </tr> 
				  <tr> 
				    <td align="right"><%=font4%><font color="#ff0000">*&nbsp;</font>E-Mail&nbsp;Address:&nbsp;</font></td>
				    <td align="left"><input name="email" size="25" maxlength="100" tabindex="4"></td>
				  </tr>
				  <tr> 
				    <td align="right"><%=font4%> Phone:&nbsp;</font></td>
				    <td align="left"><input name="phone" size="25" maxlength="20" tabindex="5"></td>
				  </tr>
				  
				  <tr> 
				    <td align="right"><%=font4%> Part# 1:&nbsp;</font></td>
				    <td align="left"><input name="partno1" size="25" maxlength="50" tabindex="6"></td>
				  </tr>
				  <tr> 
				    <td align="right"><%=font4%> Part# 2:&nbsp;</font></td>
				    <td align="left"><input name="partno2" size="25" maxlength="50" tabindex="7"></td>
				  </tr>
				  <tr> 
				    <td align="right"><%=font4%> Part# 3:&nbsp;</font></td>
				    <td align="left"><input name="partno3" size="25" maxlength="50" tabindex="8"></td>
				  </tr>
				  <tr> 
				    <td align="right"><%=font4%> Part# 4:&nbsp;</font></td>
				    <td align="left"><input name="partno4" size="25" maxlength="50" tabindex="9"></td>
				  </tr>
				  
				  <tr> 
				    <td align="right" valign="top"><%=font4%><font color="#ff0000">*&nbsp;</font>Comments:&nbsp;</td>
				    <td align="left"><textarea name="message" rows="8" wrap="virtual" cols="20" tabindex="10"></textarea></td>
				  </tr>
				  <tr> 
				    <td align="right" valign="top">&nbsp;</td>
				    <td align="left"> 
                    
<%
'Specify your captcha length here
captchaLength = 5

Function captcha(captchaLength)
	if captchaLength > 15 then captchaLength = 15
	HighestValue = left(100000000000000,captchaLength)
	lowestValue = left(999999999999999,captchaLength)
	Randomize 
	intHighestNumber = Int((HighestValue - LowestValue + 1) * Rnd) + LowestValue
	session("captcha") = Int(intHighestNumber)
	x = 1
	response.write vbcrlf & "<table width = ''>" & vbcrlf & vbtab & "<tr>" & vbcrlf
	while x <= captchaLength
		response.write vbtab & vbtab & "<td align = 'center'><img src = 'captcha.asp?captchaID=" & x & "' ></td>" & vbcrlf
		x = x + 1
	wend
	response.write vbtab & "</tr>" & vbcrlf & "</table>" & vbcrlf
End Function
%>

<%
if request("action") = "captcha" then
	if cstr(request("captcha")) = cstr(session("captcha")) then
		response.write "Correct!"
	else
		response.write "Sorry, no match."
	end if
end if
%>

                       Enter Code: <input name="captcha"> <BR />
				         <input type="submit" name="submit" src="images/b_submit.gif" border="0" tabindex="13" id="image1"  value="Submit"></td>
				  </tr>
				</table>
  </form>

it works great, but as soon as I move it over to the page I need it to and incorporate that form into it, I get a VB error. The error says:

Microsoft VBScript compilation error '800a03ea'

Syntax error

/RoHSCompliant2.asp, line 174

Function captcha(captchaLength)
^

so i know where the error is but not how to remedy it. why would it be doing this? what code in the rest of the page could pull such an error?

THANKS!

We had a similar error and it transpired our function decleration was inside a loop.

It wasn't obvious to us at first, as the function dec was inside an include, and the loop was in the parent page.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.