Link to home
Start Free TrialLog in
Avatar of Stiebel Eltron
Stiebel EltronFlag for Thailand

asked on

How to resolve the CAPTCHA script inside my ASP form?

Dear EE Experts,

Please see the attached codes that we have, kindly check & advise why does the CAPTCHA script isn't working, what I mean is if a user type it wrong, it will still send the form, it's not checking the spelling...

Please advise...
<%@LANGUAGE="VBSCRIPT"%>
<%
function TestCaptcha(byval valSession, byval valCaptcha)
	dim tmpSession
	valSession = Trim(valSession)
	valCaptcha = Trim(valCaptcha)
	if (valSession = vbNullString) or (valCaptcha = vbNullString) then
		TestCaptcha = false
	else
		tmpSession = valSession
		valSession = Trim(Session(valSession))
		Session(tmpSession) = vbNullString
		if valSession = vbNullString then
			TestCaptcha = false
		else
			valCaptcha = Replace(valCaptcha,"i","I")
			if StrComp(valSession,valCaptcha,1) = 0 then
				TestCaptcha = true
			else
				TestCaptcha = false
			end if
		end if		
	end if
end function
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">

<meta name="GENERATOR" content="Mozilla/4.7 [en] (Win98; I) [Netscape]">

<title>..:: Stiebel ::..</title>
<style TYPE="text/css">
<!--
	a
 	{
  		color:#000080;
		font-family:verdana;
		text-decoration:none;
		font-size:12px
	}
	
	
	a:active
 	{
  		color:red;

	}

	a:hover
 	{
  		color:#FF0000;
		text-decoration:none;
		cursor:crosshair;
	}
		
	table
	{
		font-family:verdana;
	}
	
	.td
	{
		font-family:verdana;
		font-size:12px;
	}

	.b
	{
		font-color:#FF0000;
		font-family:verdana;
		font-size:12px;
	}		

-->
</STYLE>

<!--validation-->

<script language="JavaScript" type="text/javascript">
if(!String.prototype.trim) {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/, '');
  };
}

function isEmail(string) {
  return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
}
function checkform ( form ) {
  // ** START **
  if (form.username.value.trim() == "") {
    alert( "Please enter your Username." );
    form.username.focus();
    return false ;
  }
  if (form.password.value.trim() == "") {
    alert( "Please enter your Password." );
    form.password.focus();
    return false ;
  }
  if (form.repassword.value.trim() == "") {
    alert( "Please retype your Password." );
    form.repassword.focus();
    return false ;
  }
  if (form.repassword.value.trim() != form.password.value.trim()) {
    alert( "Password didn't match. Please retype." );
    form.repassword.focus();
    return false ;
  }
  if (form.fname.value.trim() == "") {
    alert( "Please enter your name." );
    form.fname.focus();
    return false ;
  }
  if (form.lname.value.trim() == "") {
    alert( "Please enter your surname." );
    form.lname.focus();
    return false ;
  }
  if (form.company.value.trim() == "") {
    alert( "Please enter your company name." );
    form.company.focus();
    return false ;
  }
  if (form.address.value.trim() == "") {
    alert( "Please enter your address." );
    form.address.focus();
    return false ;
  }
  if (form.email.value.trim() == "") {
    alert( "Please enter your email address." );
    form.email.focus();
    return false ;
  }
  
  if (!isEmail(form.email.value.trim())) {
    alert("Please enter correct Email address");
	  form.email.focus();
	  return false;
  }

  if (form.telephone.value.trim() == "") {
    alert( "Please enter your Telephone#." );
    form.telephone.focus();
    return false ;
  }
  if (form.mobile.value.trim() == "") {
    alert( "Please enter your Mobile#." );
    form.mobile.focus();
    return false ;
  }
  if (form.code.value.trim() == "") {
    alert( "Please retype the confirmation code." );
    form.code.focus();
    return false ;
  }
//  if (form.remobile.value.trim() != form.mobile.value.trim()) {
//    alert( "Mobile didn't match. Please retype." );
//    form.remobile.focus();
//    return false ;
//  }
  
    // ** END **
    return true ; // allow submission
}
</script>
<!-- captcha image-->
<script language="javascript">
function RefreshImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}
</script>
<!--END-->

</head>

<body bgproperties="fixed" bgcolor="#000000" onLoad="javascript:startmenu()">

<table width="760" border="0" cellspacing="3" cellpadding="1">
  <tr>
    <td width="134"><img src="../IMG/logo_res.jpg" alt="STIEBEL ELTRON" /></td>
    <td width="620" valign="top" bgcolor="#666666"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="548" height="197">
      <param name="movie" value="homeintro20.swf" />
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <embed src="homeintro20.swf" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="548" height="197"></embed>
    </object></td>
    <td width="134" bgcolor="#FFFFFF"><img src="../IMG/white_square.png" alt="ASIA" border="0" align="top"/></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="right" bgcolor="#999999"><font face="Verdana, Geneva, sans-serif" color="#ffffff">
    <%
   '// If user is logged in show name and logout link
   If Session("loggedin") = true Then
      Response.Write "Welcome: " & Session("name")
      Response.Write "<br /><a href=""../asia/login2/logout.asp"">Logout</a>"
   Else
      Response.Write "<a href=""ste-iphoto-login.asp"" title=""CLICK TO LOGIN"">REGISTERED USERS</a>"
   End If
	%>&nbsp;
	</td>
    <td bgcolor="#666666" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left" bordercolor="#999999" bgcolor="#000000"><img src="../IMG/member.jpg" width="548" /><br></td>
    <td bgcolor="#999999" valign="top" align="center" rowspan=13>&nbsp;
		
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    	<table width="100%" border="1" bordercolor="#ffffff" cellpadding="0" bgcolor="#999999">
    		<form name="form" id="form" method="post" action="signup_result.asp" onSubmit="return checkform(this)">

    		<tr>
        		<td class="td" width="20%" align="right">First Name:</td>
           		<td width="80%"><input id="fname" name="fname" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
    		<tr>
        		<td class="td" width="20%" align="right">Last Name:</td>
           		<td width="80%"><input id="lname" name="lname" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
           	<tr>
        		<td class="td" width="20%" align="right">Email:</td>
           		<td width="80%"><input id="email" name="email" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font></b>	
            	</td>
        	</tr>

<!--            
	    	<tr>
    	    	<td class="td" width="20%" align="right">Username:</td>
	    	   	<td width="80%"><input id="username" name="username" type="text" size="25" maxlength="15" onkeyup="OnChangedUsername" />&nbsp;<b><font class="b">*</font></b>&nbsp;<input id="btnCheckAvailability" type="button" disabled="disabled" value="Check Availability" onclick="OnCheckAvailability();" />&nbsp;&nbsp;<div id="Available"></div>
                </td>
        	</tr>
-->            
    		<tr>
        		<td class="td" width="20%" align="right">Password:</td>
           		<td width="80%"><input id="password" name="password" type="password" size="25" maxlength="15" />&nbsp;<b><font class=
                "b">*</font></b>
                </td>
        	</tr>
    		<tr>
        		<td class="td" width="20%" align="right">Re-type Password:</td>
           		<td width="80%"><input id="repassword" name="repassword" type="password" size="25" maxlength="15" />&nbsp;<b><font class="b">*</font></b>
                </td>
        	</tr>
        	<tr>
        		<td class="td" width="20%" align="right">Country:</td>
           		<td width="80%"><input id="country" name="country" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font></b>	
         	   </td>
        	</tr>
	        <tr>
    	    	<td class="td" width="20%" align="right">Telephone:</td>
        	   	<td width="80%"><input id="telephone" name="telephone" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">
                *</font></b>
                </td>
        	</tr>
        	<tr>
        		<td class="td" width="20%" align="right">Mobile:</td>
           		<td width="80%"><input id="mobile" name="mobile" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">*
                </font></b>
                </td>
        	</tr>
	    	<tr>
    	    	<td class="td" width="20%" align="right">Company:</td>
        	   	<td width="80%"><input id="company" name="company" type="text" size="50" maxlength="25" />&nbsp;<b><font class="b">*
                </font></b>
                </td>
        	</tr>
    		<tr valign="top">
        		<td class="td" width="20%" align="right">Address:</td>
           		<td width="80%"><textarea name="address" id="address" rows="4" cols="39"></textarea>&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
	        <tr>
    	    	<td class="td" width="20%" align="right">Confirm code:&nbsp;
				</td> 
           		<td width="80%">
            		<img id="imgCaptcha" src="captcha.asp" /><br />
                    <a href="javascript:void(0)" onclick="RefreshImage('imgCaptcha')">Change Image</a><br />
		            <input id="code" name="code" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">*</font></b>
                </td>
        	</tr>
	        <tr>
        		<td class="td" width="20%" align="right">&nbsp;</td>
           		<td width="80%"><input name="Submit" type="submit" value="SUBMIT FORM" onclick="checkform();" />&nbsp;
            		<input name="Reset" type="reset" value="RESET FORM" onClick="return confirm('Are you sure you want to reset the 
                    form?')" />
                </td>
        	</tr>
			<%
			if not IsEmpty(Request.Form("Submit")) then
			Response.Write("<tr><td colspan=""2"" align=""center"">")
			if TestCaptcha("ASPCAPTCHA", Request.Form("captchacode")) then
			Response.Write("<b style=""color:#00CC33"">The code you enter verified.</b>")
			else
			Response.Write("<b style=""color:#FF0000"">You entered the wrong code.</b>")
			end if
			Response.Write("</td></tr>" & vbCrLf)
			end if
			%>


        </form>
        
        <!--javascript-->
        <script language="JavaScript" type="text/javascript">
		//If our user enters data in the username input, then we need to enable our button
		function OnChangedUsername()
		{
		if(document.form.username.value == "")
		{
		document.form.btnCheckAvailability.disabled = true;
		}
		else
		{
		document.form.btnCheckAvailability.disabled = false;
		}
		}
		function OnCheckAvailability()
		{
		if(window.XMLHttpRequest)
		{
		oRequest = new XMLHttpRequest();
		}
		else if(window.ActiveXObject)
		{
		oRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}

		oRequest.open("POST", "AJAX.asp", true);
		oRequest.onreadystatechange = UpdateCheckAvailability;
		oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oRequest.send("strCmd=availability&strUsername=" + document.form.username.value);
		}
		function UpdateCheckAvailability()
		{
		if(oRequest.readyState == 4)
		{ 
		if(oRequest.status == 200)
		{
		document.getElementById("Available").innerHTML = oRequest.responseText;
		}
		else
		{
		document.getElementById("Available").innerHTML = "Asychronous Error";
		}
		}
		}
		</script>
        <!--END-->
    </table>
    </td>
  </tr>
   <tr>
    <td>&nbsp;</td>
    <td align="center" bgcolor="#ffffff">
    	<a href = "javascript:history.back()"><font size="0.5e">BACK</font></a>
    </td>
  </tr>
</table>

</body>
</html>

Open in new window

Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Have a look here.

working LIVE example
http://ee.cffcs.com/Q_24688967/Q_24688967.asp
Code
http://ee.cffcs.com/Q_24688967/Q_24688967.zip

Any questions, let me know.
Read the liner notes within the code.

Carrzkiss
Avatar of Stiebel Eltron

ASKER

Hello there carrzkiss! Nice to hear from you again!
I tried the working LIVE example from the link that you advised, I'm not sure why I received this error:
The error was invalid-site-private-key
though I make sure that I typed the 2 words correct...

Anyway, regarding with the script from the zip file, I'll check it first then if have questions, will let you know asap!

Thank you!
I'll check in on it.
I have not messed with this script in a long time.
Will get back with you in a bit.
Btw, do I need to insert those scripts (Q_24688967.asp) under </head>, I mean inside <body>?

Please advise...
Re-download the code, as I changed it.

working LIVE example
http://ee.cffcs.com/Q_24688967/Q_24688967.asp
Code
http://ee.cffcs.com/Q_24688967/Q_24688967.zip

You also need to obtain your sites KEYS from here.
http://recaptcha.net/

Carrzkiss
Just follow the way that I have the code
I got already the Public Keys & Private Keys, will this work even though we're testing it locally? And what should we do with those keys?
Ok, how about with the "reCapthca.asp" file, what should I do with the script, as I received error on the captcha part: "Input error: k: Format of site key was invalid"

Please advise...
OK, I have created a new script, as I stopped using the one that is in the example that I provided.
This new one using AJAX, and submits to the same page, this will also make your site stand out a little more as well.

http://www.cffcs.com/Main.asp?Entry=25

Sign up on the site to download the code.
To view the Live Example
http://www.cffcs.com/Tutorials/carrzkiss/25/Load.asp

Remember to add in your Private and Public keys where they belong in both the
Load.asp
Pass.asp
Pages.

Good Luck and let me know if you have any issues with this newly created script.
Carrzkiss
Actually I found that Private & Public keys already and input that already, but I'm not sure why does it has error @ line 286 which is: if TestCaptcha("ASPCAPTCHA", Request.Form("captchacode")) then

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'TestCaptcha'

/iphoto/asia2/login/ste-iphoto-signup1.asp, line 286


And another thing is, it's not checking if some fields are filled already or not, I tried to mistype the password, it didn't prompt & even the captcha.
I'm attaching my script, kindly check where I made mistake...

Thank you!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">

<meta name="GENERATOR" content="Mozilla/4.7 [en] (Win98; I) [Netscape]">

<title>..:: New User Registration ::..</title>
<style TYPE="text/css">
<!--
	a
 	{
  		color:#000080;
		font-family:verdana;
		text-decoration:none;
		font-size:12px
	}
	
	
	a:active
 	{
  		color:red;

	}

	a:hover
 	{
  		color:#FF0000;
		text-decoration:none;
		cursor:crosshair;
	}
		
	table
	{
		font-family:verdana;
	}
	
	.td
	{
		font-family:verdana;
		font-size:12px;
	}

	.b
	{
		font-color:#FF0000;
		font-family:verdana;
		font-size:12px;
	}		

-->
</STYLE>

<!--validation-->

<script language="JavaScript" type="text/javascript">
if(!String.prototype.trim) {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/, '');
  };
}

function isEmail(string) {
  return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
}
function checkform ( form ) {
  // ** START **
  if (form.username.value.trim() == "") {
    alert( "Please enter your Username." );
    form.username.focus();
    return false ;
  }
  if (form.password.value.trim() == "") {
    alert( "Please enter your Password." );
    form.password.focus();
    return false ;
  }
  if (form.repassword.value.trim() == "") {
    alert( "Please retype your Password." );
    form.repassword.focus();
    return false ;
  }
  if (form.repassword.value.trim() != form.password.value.trim()) {
    alert( "Password didn't match. Please retype." );
    form.repassword.focus();
    return false ;
  }
  if (form.fname.value.trim() == "") {
    alert( "Please enter your name." );
    form.fname.focus();
    return false ;
  }
  if (form.lname.value.trim() == "") {
    alert( "Please enter your surname." );
    form.lname.focus();
    return false ;
  }
  if (form.company.value.trim() == "") {
    alert( "Please enter your company name." );
    form.company.focus();
    return false ;
  }
  if (form.address.value.trim() == "") {
    alert( "Please enter your address." );
    form.address.focus();
    return false ;
  }
  if (form.email.value.trim() == "") {
    alert( "Please enter your email address." );
    form.email.focus();
    return false ;
  }
  
  if (!isEmail(form.email.value.trim())) {
    alert("Please enter correct Email address");
	  form.email.focus();
	  return false;
  }

  if (form.telephone.value.trim() == "") {
    alert( "Please enter your Telephone#." );
    form.telephone.focus();
    return false ;
  }
  if (form.mobile.value.trim() == "") {
    alert( "Please enter your Mobile#." );
    form.mobile.focus();
    return false ;
  }
  if (form.code.value.trim() == "") {
    alert( "Please retype the confirmation code." );
    form.code.focus();
    return false ;
  }
//  if (form.remobile.value.trim() != form.mobile.value.trim()) {
//    alert( "Mobile didn't match. Please retype." );
//    form.remobile.focus();
//    return false ;
//  }
  
    // ** END **
    return true ; // allow submission
}
</script>

</head>

<%
' On Error Resume Next

' Classsic ASP pages created by Andre F Bruton
' E-mail: andre@bruton.co.za
' Date: 2008/01/19

recaptcha_challenge_field  = Request("recaptcha_challenge_field")
recaptcha_response_field   = Request("recaptcha_response_field")
recaptcha_private_key      = "6Lc73cgSAAAAAL3HAD81jkLhDpFobzlCPHGvvGVi"
recaptcha_public_key       = "6Lc73cgSAAAAAALT8Nge2rLyJsiQjWZqwspCc8wg"
'cTemp = recaptcha_confirm(recaptcha_private_key, recaptcha_challenge_field, recaptcha_response_field)
%>
<%

'else
cTemp = recaptcha_confirm(recaptcha_private_key, recaptcha_challenge_field, recaptcha_response_field)
If cTemp <> "" Then 
if request.Form("Pass") = "Form" then
response.Write"<br />The error was <strong>"&cTemp&"</strong>"
end if
%>

<body bgproperties="fixed" bgcolor="#000000" onLoad="javascript:startmenu()">

<table width="760" border="0" cellspacing="3" cellpadding="1">
  <tr>
    <td width="134"><img src="../IMG/logo_res.jpg" alt="STIEBEL ELTRON" /></td>
    <td width="620" valign="top" bgcolor="#666666"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="548" height="197">
      <param name="movie" value="homeintro20.swf" />
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <embed src="homeintro20.swf" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="548" height="197"></embed>
    </object></td>
    <td width="134" bgcolor="#FFFFFF"><img src="../IMG/white_square.png" alt="ASIA" border="0" align="top"/></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="right" bgcolor="#999999"><font face="Verdana, Geneva, sans-serif" color="#ffffff">
		&nbsp;
	</td>
    <td bgcolor="#666666" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left" bordercolor="#999999" bgcolor="#000000"><img src="../IMG/member.jpg" width="548" /><br></td>
    <td bgcolor="#999999" valign="top" align="center" rowspan=13>&nbsp;
		
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    	<form action="" method="post">
			<% Else %>
    	<form name="form" id="form" method="post" action="signup_result.asp" onSubmit="return checkform(this)"><%end if%>
		<input type="hidden" name="Pass" value="Form" />
    	<table width="100%" border="1" bordercolor="#ffffff" cellpadding="0" bgcolor="#999999">
    		<tr>
        		<td class="td" width="23%" align="right">First Name:</td>
           		<td width="77%"><input id="fname" name="fname" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
    		<tr>
        		<td class="td" width="23%" align="right">Last Name:</td>
           		<td width="77%"><input id="lname" name="lname" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
           	<tr>
        		<td class="td" width="23%" align="right">Email:</td>
           		<td width="77%"><input id="email" name="email" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font></b>	
            	</td>
        	</tr>
	   		<tr>
        		<td class="td" width="23%" align="right">Password:</td>
           		<td width="77%"><input id="password" name="password" type="password" size="25" maxlength="15" />&nbsp;<b><font class=
                "b">*</font></b>
                </td>
        	</tr>
    		<tr>
        		<td class="td" width="23%" align="right">Re-type Password:</td>
           		<td width="77%"><input id="repassword" name="repassword" type="password" size="25" maxlength="15" />&nbsp;<b><font class="b">*</font></b>
                </td>
        	</tr>
        	<tr>
        		<td class="td" width="23%" align="right">Country:</td>
           		<td width="77%"><input id="country" name="country" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font></b>	
         	   </td>
        	</tr>
	        <tr>
    	    	<td class="td" width="23%" align="right">Telephone:</td>
        	   	<td width="77%"><input id="telephone" name="telephone" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">
                *</font></b>
                </td>
        	</tr>
        	<tr>
        		<td class="td" width="23%" align="right">Mobile:</td>
           		<td width="77%"><input id="mobile" name="mobile" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">*
                </font></b>
                </td>
        	</tr>
	    	<tr>
    	    	<td class="td" width="23%" align="right">Company:</td>
        	   	<td width="77%"><input id="company" name="company" type="text" size="50" maxlength="25" />&nbsp;<b><font class="b">*
                </font></b>
                </td>
        	</tr>
    		<tr valign="top">
        		<td class="td" width="23%" align="right">Address:</td>
           		<td width="77%"><textarea name="address" id="address" rows="4" cols="39"></textarea>&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
	        <tr>
    	    	<td class="td" width="23%" align="right">Confirm code:&nbsp;
				</td> 
           		<td width="77%">
					<%=recaptcha_challenge_writer(recaptcha_public_key)%>
                </td>
        	</tr>
	        <tr>
        		<td class="td" width="23%" align="right">&nbsp;</td>
           		<td width="77%"><input name="Submit" type="submit" value="SUBMIT FORM" onclick="checkform();" />&nbsp;
            		<input name="Reset" type="reset" value="RESET FORM" onClick="return confirm('Are you sure you want to reset the 
                    form?')" />
                </td>
        	</tr>
			<%
			if not IsEmpty(Request.Form("Submit")) then
			Response.Write("<tr><td colspan=""2"" align=""center"">")
			if TestCaptcha("ASPCAPTCHA", Request.Form("captchacode")) then
			Response.Write("<b style=""color:#00CC33"">The code you enter verified.</b>")
			else
			Response.Write("<b style=""color:#FF0000"">You entered the wrong code.</b>")
			end if
			Response.Write("</td></tr>" & vbCrLf)
			end if
			%>
			
            <!--#include file="reCaptcha.asp"-->

        </form>
        
        <!--javascript-->
        <script language="JavaScript" type="text/javascript">
		//If our user enters data in the username input, then we need to enable our button
		function OnChangedUsername()
		{
		if(document.form.username.value == "")
		{
		document.form.btnCheckAvailability.disabled = true;
		}
		else
		{
		document.form.btnCheckAvailability.disabled = false;
		}
		}
		function OnCheckAvailability()
		{
		if(window.XMLHttpRequest)
		{
		oRequest = new XMLHttpRequest();
		}
		else if(window.ActiveXObject)
		{
		oRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}

		oRequest.open("POST", "AJAX.asp", true);
		oRequest.onreadystatechange = UpdateCheckAvailability;
		oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oRequest.send("strCmd=availability&strUsername=" + document.form.username.value);
		}
		function UpdateCheckAvailability()
		{
		if(oRequest.readyState == 4)
		{ 
		if(oRequest.status == 200)
		{
		document.getElementById("Available").innerHTML = oRequest.responseText;
		}
		else
		{
		document.getElementById("Available").innerHTML = "Asychronous Error";
		}
		}
		}
		</script>
        <!--END-->
    </table>
    </td>
  </tr>
   <tr>
    <td>&nbsp;</td>
    <td align="center" bgcolor="#ffffff">
    	<a href = "javascript:history.back()"><font size="0.5e">BACK</font></a>
    </td>
  </tr>
</table>

</body>
</html>

Open in new window

I keep receiving error on this line: if TestCaptcha("ASPCAPTCHA", Request.Form("captchacode")) then

I even tried path to your script from the first set that you sent to me (Q_24688967.asp, reCaptcha.asp, ThankYou.asp), but still I received an error result...

Hope to hear again soon... :-)
What is TestCaptcha
What does it do?

If you would have taken the code form the link that I provided above.

(Here)
http://www.cffcs.com/Main.asp?Entry=25

Sign up on the site to download the code.
To view the Live Example
http://www.cffcs.com/Tutorials/carrzkiss/25/Load.asp

And just added that into your project, you will not be having the issue that you are having right now.
As the TestCaptcha line is not really doing anything for what the ReCaptcha is for.
Hello there carrzkiss! I downloaded & tried the code from the link that you provided, please see the attached scripts that I did & kindly check & let me know which part I made a mistake, as I'm not receiving any result. After I filled-up the form, typed the captcha words, nothing happens, it just stayed on the same page... even I intentionally type it wrong for the captcha words, still the same, nothing happens...

I was wonderin with this line:
<form name="ContactForm" action="pass.asp" method="post" onSubmit="xmlhttpPost('pass.asp', 'ContactForm', 'Contactdiv', '<img src=\'graph/pleasewait.gif\'>'); return false;">

How can my form can go to my result page if the action would be calling the "pass.asp" page?
Kindly check the attached script for it...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Utilities/iasutil.asp"-->
<%
'This is the Recaptcha information, keep this at the top of the page.
recaptcha_challenge_field  = Request("recaptcha_challenge_field")
recaptcha_response_field   = Request("recaptcha_response_field")
recaptcha_private_key      = "6Lc73cgSAAAAAL3HAD81jkLhDpFobzlCPHGvvGVi"
recaptcha_public_key       = "6Lc73cgSAAAAAALT8Nge2rLyJsiQjWZqwspCc8wg"
%>
<!--#include file="Utilities/Recaptcha.asp"-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">

<meta name="GENERATOR" content="Mozilla/4.7 [en] (Win98; I) [Netscape]">

<title>..:: New User Registration ::..</title>
<style TYPE="text/css">
<!--
	a
 	{
  		color:#000080;
		font-family:verdana;
		text-decoration:none;
		font-size:12px
	}
	
	
	a:active
 	{
  		color:red;

	}

	a:hover
 	{
  		color:#FF0000;
		text-decoration:none;
		cursor:crosshair;
	}
		
	table
	{
		font-family:verdana;
	}
	
	.td
	{
		font-family:verdana;
		font-size:12px;
	}

	.b
	{
		font-color:#FF0000;
		font-family:verdana;
		font-size:12px;
	}		

-->
</STYLE>

<!--validation-->

<script language="JavaScript" type="text/javascript">
if(!String.prototype.trim) {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/, '');
  };
}

function isEmail(string) {
  return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
}
function checkform ( form ) {
  // ** START **
  //  if (form.username.value.trim() == "") {
  //	alert( "Please enter your Username." );-->
  //	 form.username.focus();-->
  //  return false ;-->
  //}
  if (form.password.value.trim() == "") {
    alert( "Please enter your Password." );
    form.password.focus();
    return false ;
  }
  if (form.repassword.value.trim() == "") {
    alert( "Please retype your Password." );
    form.repassword.focus();
    return false ;
  }
  if (form.repassword.value.trim() != form.password.value.trim()) {
    alert( "Password didn't match. Please retype." );
    form.repassword.focus();
    return false ;
  }
  if (form.fname.value.trim() == "") {
    alert( "Please enter your name." );
    form.fname.focus();
    return false ;
  }
  if (form.lname.value.trim() == "") {
    alert( "Please enter your surname." );
    form.lname.focus();
    return false ;
  }
  if (form.company.value.trim() == "") {
    alert( "Please enter your company name." );
    form.company.focus();
    return false ;
  }
  if (form.address.value.trim() == "") {
    alert( "Please enter your address." );
    form.address.focus();
    return false ;
  }
  if (form.email.value.trim() == "") {
    alert( "Please enter your email address." );
    form.email.focus();
    return false ;
  }
  
  if (!isEmail(form.email.value.trim())) {
    alert("Please enter correct Email address");
	  form.email.focus();
	  return false;
  }

  if (form.telephone.value.trim() == "") {
    alert( "Please enter your Telephone#." );
    form.telephone.focus();
    return false ;
  }
  if (form.mobile.value.trim() == "") {
    alert( "Please enter your Mobile#." );
    form.mobile.focus();
    return false ;
  }
  //if (form.code.value.trim() == "") {
  //  alert( "Please retype the confirmation code." );
  //  form.code.focus();
  //  return false ;
  //}
//  if (form.remobile.value.trim() != form.mobile.value.trim()) {
//    alert( "Mobile didn't match. Please retype." );
//    form.remobile.focus();
//    return false ;
//  }
  
    // ** END **
    return true ; // allow submission
}
</script>

<script src="Utilities/ajaxsbmt.js" type="text/javascript"></script>

</head>


<body bgproperties="fixed" bgcolor="#000000" onLoad="javascript:startmenu()">

<table width="760" border="0" cellspacing="3" cellpadding="1">
  <tr>
    <td width="134"><img src="../IMG/logo_res.jpg" alt="STIEBEL ELTRON" /></td>
    <td width="620" valign="top" bgcolor="#666666"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="548" height="197">
      <param name="movie" value="homeintro20.swf" />
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <embed src="homeintro20.swf" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="548" height="197"></embed>
    </object></td>
    <td width="134" bgcolor="#FFFFFF"><img src="../IMG/white_square.png" alt="ASIA" border="0" align="top"/></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="right" bgcolor="#999999"><font face="Verdana, Geneva, sans-serif" color="#ffffff">
		&nbsp;
	</td>
    <td bgcolor="#666666" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="left" bordercolor="#999999" bgcolor="#000000"><img src="../IMG/member.jpg" width="548" /><br></td>
    <td bgcolor="#999999" valign="top" align="center" rowspan=13>&nbsp;
		
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    	<form name="ContactForm" action="pass.asp" method="post" onSubmit="xmlhttpPost('pass.asp', 'ContactForm', 'Contactdiv', '<img src=\'graph/pleasewait.gif\'>'); return false;">

        <!--<'form name="form" id="form" method="post" action="signup_result1.asp" onSubmit="return checkform(this)"><'%end if%>
		<input type="hidden" name="Pass" value="Form" />-->
    	<table width="100%" border="1" bordercolor="#ffffff" cellpadding="0" bgcolor="#999999">
    		<tr>
        		<td class="td" width="23%" align="right">First Name:</td>
           		<td width="77%"><input id="fname" name="fname" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
    		<tr>
        		<td class="td" width="23%" align="right">Last Name:</td>
           		<td width="77%"><input id="lname" name="lname" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
           	<tr>
        		<td class="td" width="23%" align="right">Email:</td>
           		<td width="77%"><input id="email" name="email" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font></b>	
            	</td>
        	</tr>
	   		<tr>
        		<td class="td" width="23%" align="right">Password:</td>
           		<td width="77%"><input id="password" name="password" type="password" size="25" maxlength="15" />&nbsp;<b><font class=
                "b">*</font></b>
                </td>
        	</tr>
    		<tr>
        		<td class="td" width="23%" align="right">Re-type Password:</td>
           		<td width="77%"><input id="repassword" name="repassword" type="password" size="25" maxlength="15" />&nbsp;<b><font class="b">*</font></b>
                </td>
        	</tr>
        	<tr>
        		<td class="td" width="23%" align="right">Country:</td>
           		<td width="77%"><input id="country" name="country" type="text" size="50" maxlength="50" />&nbsp;<b><font class="b">*</font></b>	
         	   </td>
        	</tr>
	        <tr>
    	    	<td class="td" width="23%" align="right">Telephone:</td>
        	   	<td width="77%"><input id="telephone" name="telephone" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">
                *</font></b>
                </td>
        	</tr>
        	<tr>
        		<td class="td" width="23%" align="right">Mobile:</td>
           		<td width="77%"><input id="mobile" name="mobile" type="text" size="25" maxlength="15" />&nbsp;<b><font class="b">*
                </font></b>
                </td>
        	</tr>
	    	<tr>
    	    	<td class="td" width="23%" align="right">Company:</td>
        	   	<td width="77%"><input id="company" name="company" type="text" size="50" maxlength="25" />&nbsp;<b><font class="b">*
                </font></b>
                </td>
        	</tr>
    		<tr valign="top">
        		<td class="td" width="23%" align="right">Address:</td>
           		<td width="77%"><textarea name="address" id="address" rows="4" cols="39"></textarea>&nbsp;<b><font class="b">*</font>
                </b>
                </td>
        	</tr>
	        <tr>
    	    	<td class="td" width="23%" align="right">Confirm code:&nbsp;
				</td> 
           		<td width="77%">
					<%=recaptcha_challenge_writer(recaptcha_public_key)%>
                </td>
        	</tr>
	        <tr>
        		<td class="td" width="23%" align="right"><%=recaptcha_challenge_writer(recaptcha_public_key)%></td>
           		<td width="77%"><input name="Submit" type="submit" value="SUBMIT FORM" onclick="checkform();" />&nbsp;
            		<input name="Reset" type="reset" value="RESET FORM" onClick="return confirm('Are you sure you want to reset the 
                    form?')" />
                </td>
        	</tr>
			<%
			if not IsEmpty(Request.Form("Submit")) then
			Response.Write("<tr><td colspan=""2"" align=""center"">")
			if TestCaptcha("ASPCAPTCHA", Request.Form("captchacode")) then
			Response.Write("<b style=""color:#00CC33"">The code you enter verified.</b>")
			else
			Response.Write("<b style=""color:#FF0000"">You entered the wrong code.</b>")
			end if
			Response.Write("</td></tr>" & vbCrLf)
			end if
			%>
			
            <!--#include file="reCaptcha.asp"-->

        </form>
        
        <!--javascript-->
        <script language="JavaScript" type="text/javascript">
		//If our user enters data in the username input, then we need to enable our button
		function OnChangedUsername()
		{
		if(document.form.username.value == "")
		{
		document.form.btnCheckAvailability.disabled = true;
		}
		else
		{
		document.form.btnCheckAvailability.disabled = false;
		}
		}
		function OnCheckAvailability()
		{
		if(window.XMLHttpRequest)
		{
		oRequest = new XMLHttpRequest();
		}
		else if(window.ActiveXObject)
		{
		oRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}

		oRequest.open("POST", "AJAX.asp", true);
		oRequest.onreadystatechange = UpdateCheckAvailability;
		oRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oRequest.send("strCmd=availability&strUsername=" + document.form.username.value);
		}
		function UpdateCheckAvailability()
		{
		if(oRequest.readyState == 4)
		{ 
		if(oRequest.status == 200)
		{
		document.getElementById("Available").innerHTML = oRequest.responseText;
		}
		else
		{
		document.getElementById("Available").innerHTML = "Asychronous Error";
		}
		}
		}
		</script>
        <!--END-->
    </table>
    </td>
  </tr>
   <tr>
    <td>&nbsp;</td>
    <td align="center" bgcolor="#ffffff">
    	<a href = "javascript:history.back()"><font size="0.5e">BACK</font></a>
    </td>
  </tr>


</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
From your message:
>>The Q_27384816.asp is your main page.
It sends the information to the Pass.asp page, and from there, it checks to make sure that all fields
Have been field out before submitting.<<

-- so where do I need to insert my signup_result page?
<form name="form" id="form" method="post" action="signup_result1.asp" onSubmit="return checkform(this)">

Because it should have a Thank You page after the user fills up & submits the form...
I tried your link: http://ee.cffcs.com/Q_27384816/Q_27384816.asp
Fill up the form, then submit it. I filled up everything so I got the message below: "The information has been submitted successfully!"
It only stays on that same page, didn't go anywhere...
I do not know what else to tell you.

> The code is AJAX, which means that it submits the form, without refreshing the page.

This is the way everything is being done today, if you choose not to do it this way, then you can use some other method.
I am sorry, but I cannot work on this project anymore.

Good Luck

Carrzkiss
I would still give u points....
:-)
To answer your question, replace the
Forms action with action="signup_result1.asp"

And then take the information form the Pass.asp page and implement it int he
signup_result1.asp page.

You DO NOT need the Javascript Validation script that you are currently using
As the Pass.asp script, SHOWS you how to validate using VBScript in ASP.

This is a LOT safer than the JavaScript code.

Good Luck
Carrzkiss
BUT, do you understand how this code works and how this code makes your site work better and is safer than your previous code?

If you do not understand that, then what we have done here is for nothing.
@carrzkiss, sorry for the late reply, I fell asleep last night after I give u points, just now I open EE... :-)
Anyway, I understand the codes & I would really remove those Javascripts as I know it's no use anymore, with the scripts for validation that you made...

On Monday, I'll trace those 2 files, signup_result1.asp & pass.asp

Thanks a lot!
OK, just wanted to make sure that you understood what is going on in the codes.
I use AJAX in nearly everything that I do, it makes it a LOT easier to work for the end-user.

Have a good weekend.
Carrzkiss