Comptrib
asked on
Want to run Captcha on only one of my two action button
I have a Captcha installed on my "Subcribe to Mailing List" form that runs well. The only thing is that I also have a "Unsubscribe" button on the same form and it also calls the same Captcha. How can I have the Captcha to run only on the "Subscribe" button and not the "Unsubscribe"?
The CAPTCHA comes from a Dreamweaver Plug-in
http://www.hotdreamweaver.com/form-captcha
Thank you.
The CAPTCHA comes from a Dreamweaver Plug-in
http://www.hotdreamweaver.com/form-captcha
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are using HTML "buttons", e.g.,
The form post above will pass either:
1- captcha=default and subscribe=1
or
1- captcha=default and unsubscribe=1
So you can use whatever the appropriate server-side code for detecting the form post value to see if
Request("subscribe") = "1"
or
Request("unsubscribe") = "1"
<input type="text" name="captcha" value="default"/>
<button name="subscribe" value="1" />Subscribe</button>
<button name="unsubscribe" value="1" />Unsubscribe</button>
The form post above will pass either:
1- captcha=default and subscribe=1
or
1- captcha=default and unsubscribe=1
So you can use whatever the appropriate server-side code for detecting the form post value to see if
Request("subscribe") = "1"
or
Request("unsubscribe") = "1"
ASKER
The two buttons are calling the same function with a Value of "0" or "1". I'm just not sure of what to write to bypass the Captcha if the value is "0".
Here's the code;
<div class="indent1"><input type="button" id="Subscribe" name="Subscribe" value="Subscribe" onClick="javascript:submit Form(this. form, 1)" />
</div>
<br />
<p class="indentReduceText">< em>Fields marked with ** are required.</em></p>
<hr />
<p>If you are a subscriber and wish to be removed from our <em>Mailing List</em>, please enter your<br />
e-mail address and click on the <strong>Unsubscribe</stron g> button.</p>
<div class="indent1">
<div class="reducetext">
<label for="unsubscribeEmail">E-m ail Address:</label>
</div>
</div>
<input name="email2" id="unsubscribeEmail" type="text" size="30" maxlength="125" />
<br />
<div class="indent1">
<input type="submit" id="Unsubscribe" name="Unsubscribe" value="Unsubscribe" onClick="javascript:submit Form(this. form, 0)" />
</div>
<input type="hidden" name="hdwfail" id="hdwfail" value="MailingList-eng.asp ?hdwmsg=in valid" />
</form>
Here's the code;
<div class="indent1"><input type="button" id="Subscribe" name="Subscribe" value="Subscribe" onClick="javascript:submit
</div>
<br />
<p class="indentReduceText"><
<hr />
<p>If you are a subscriber and wish to be removed from our <em>Mailing List</em>, please enter your<br />
e-mail address and click on the <strong>Unsubscribe</stron
<div class="indent1">
<div class="reducetext">
<label for="unsubscribeEmail">E-m
</div>
</div>
<input name="email2" id="unsubscribeEmail" type="text" size="30" maxlength="125" />
<br />
<div class="indent1">
<input type="submit" id="Unsubscribe" name="Unsubscribe" value="Unsubscribe" onClick="javascript:submit
</div>
<input type="hidden" name="hdwfail" id="hdwfail" value="MailingList-eng.asp
</form>
Can you post the "function submitForm()"
Is there are server-side code that verifies the captcha or is it all client-side?
Is there are server-side code that verifies the captcha or is it all client-side?
ASKER
This is the code;
<script language=vbscript runat=server>
Sub HDWCaptchaValidation
If (Request.QueryString("hdwt est") = "captchainstalled") Then
Response.Write "Captcha verification code installed."
Response.End
End If
If (UCase(Request.ServerVaria bles("REQU EST_METHOD ")) = "POST") OR (Request.QueryString.Count >= 4) Then
Dim SessionCAPTCHA, CheckCAPTCHA, HDWCaptchaBack, HDWname
SessionCAPTCHA = Trim(CStr(Session("HDWCAPT CHA")))
Session("CAPTCHA") = ""
HDWCaptchaBack = Request.Form("hdwfail")
If (HDWCaptchaBack = "") Then HDWCaptchaBack = Request.QueryString("hdwfa il")
For Each HDWname in Request.QueryString
Response.Cookies("hdw" & HDWname) = Request.QueryString(HDWnam e)
Next
For Each HDWname in Request.Form
Response.Cookies("hdw" & HDWname) = Request.Form(HDWname)
Next
For Each HDWname in Request.Cookies
On Error Resume Next
If (Left(HDWname,3) = "hdw") AND (Request.QueryString(Right (HDWname,L en(HDWname )-3)) = "") AND (Request.Form(Right(HDWnam e,Len(HDWn ame)-3)) = "") Then
If (Err.Description = "") Then Response.Cookies(HDWname) = ""
End If
Next
If (Len(SessionCAPTCHA) < 1) OR ((Request.Form("hdcaptcha" ) = "") AND (Request.QueryString("hdca ptcha") = "")) OR ((SessionCAPTCHA <> CStr(Request.Form("hdcaptc ha"))) AND (SessionCAPTCHA <> CStr(Request.QueryString(" hdcaptcha" )))) Then
Response.Redirect HDWCaptchaBack
Response.End
End If
For Each HDWname in Request.Cookies
If (Left(HDWname,3) = "hdw") Then
Response.Cookies(HDWname) = ""
End If
Next
End If
End Sub
</script>
<% HDWCaptchaValidation %><script language=vbscript runat=server>
Sub HDWCaptchaValidation
If (Request.QueryString("hdwt est") = "captchainstalled") Then
Response.Write "Captcha verification code installed."
Response.End
End If
If (UCase(Request.ServerVaria bles("REQU EST_METHOD ")) = "POST") OR (Request.QueryString.Count >= 4) Then
Dim SessionCAPTCHA, CheckCAPTCHA, HDWCaptchaBack, HDWname
SessionCAPTCHA = Trim(CStr(Session("HDWCAPT CHA")))
Session("CAPTCHA") = ""
HDWCaptchaBack = Request.Form("hdwfail")
If (HDWCaptchaBack = "") Then HDWCaptchaBack = Request.QueryString("hdwfa il")
For Each HDWname in Request.QueryString
Response.Cookies("hdw" & HDWname) = Request.QueryString(HDWnam e)
Next
For Each HDWname in Request.Form
Response.Cookies("hdw" & HDWname) = Request.Form(HDWname)
Next
For Each HDWname in Request.Cookies
On Error Resume Next
If (Left(HDWname,3) = "hdw") AND (Request.QueryString(Right (HDWname,L en(HDWname )-3)) = "") AND (Request.Form(Right(HDWnam e,Len(HDWn ame)-3)) = "") Then
If (Err.Description = "") Then Response.Cookies(HDWname) = ""
End If
Next
If (Len(SessionCAPTCHA) < 1) OR ((Request.Form("hdcaptcha" ) = "") AND (Request.QueryString("hdca ptcha") = "")) OR ((SessionCAPTCHA <> CStr(Request.Form("hdcaptc ha"))) AND (SessionCAPTCHA <> CStr(Request.QueryString(" hdcaptcha" )))) Then
Response.Redirect HDWCaptchaBack
Response.End
End If
For Each HDWname in Request.Cookies
If (Left(HDWname,3) = "hdw") Then
Response.Cookies(HDWname) = ""
End If
Next
End If
End Sub
</script>
Thanks for the help!
<script language=vbscript runat=server>
Sub HDWCaptchaValidation
If (Request.QueryString("hdwt
Response.Write "Captcha verification code installed."
Response.End
End If
If (UCase(Request.ServerVaria
Dim SessionCAPTCHA, CheckCAPTCHA, HDWCaptchaBack, HDWname
SessionCAPTCHA = Trim(CStr(Session("HDWCAPT
Session("CAPTCHA") = ""
HDWCaptchaBack = Request.Form("hdwfail")
If (HDWCaptchaBack = "") Then HDWCaptchaBack = Request.QueryString("hdwfa
For Each HDWname in Request.QueryString
Response.Cookies("hdw" & HDWname) = Request.QueryString(HDWnam
Next
For Each HDWname in Request.Form
Response.Cookies("hdw" & HDWname) = Request.Form(HDWname)
Next
For Each HDWname in Request.Cookies
On Error Resume Next
If (Left(HDWname,3) = "hdw") AND (Request.QueryString(Right
If (Err.Description = "") Then Response.Cookies(HDWname) = ""
End If
Next
If (Len(SessionCAPTCHA) < 1) OR ((Request.Form("hdcaptcha"
Response.Redirect HDWCaptchaBack
Response.End
End If
For Each HDWname in Request.Cookies
If (Left(HDWname,3) = "hdw") Then
Response.Cookies(HDWname) = ""
End If
Next
End If
End Sub
</script>
<% HDWCaptchaValidation %><script language=vbscript runat=server>
Sub HDWCaptchaValidation
If (Request.QueryString("hdwt
Response.Write "Captcha verification code installed."
Response.End
End If
If (UCase(Request.ServerVaria
Dim SessionCAPTCHA, CheckCAPTCHA, HDWCaptchaBack, HDWname
SessionCAPTCHA = Trim(CStr(Session("HDWCAPT
Session("CAPTCHA") = ""
HDWCaptchaBack = Request.Form("hdwfail")
If (HDWCaptchaBack = "") Then HDWCaptchaBack = Request.QueryString("hdwfa
For Each HDWname in Request.QueryString
Response.Cookies("hdw" & HDWname) = Request.QueryString(HDWnam
Next
For Each HDWname in Request.Form
Response.Cookies("hdw" & HDWname) = Request.Form(HDWname)
Next
For Each HDWname in Request.Cookies
On Error Resume Next
If (Left(HDWname,3) = "hdw") AND (Request.QueryString(Right
If (Err.Description = "") Then Response.Cookies(HDWname) = ""
End If
Next
If (Len(SessionCAPTCHA) < 1) OR ((Request.Form("hdcaptcha"
Response.Redirect HDWCaptchaBack
Response.End
End If
For Each HDWname in Request.Cookies
If (Left(HDWname,3) = "hdw") Then
Response.Cookies(HDWname) = ""
End If
Next
End If
End Sub
</script>
Thanks for the help!
ASKER
You may want to see this instead...this is where the CAPTCHA image is located ;
Text file attached
CAPTCHA.txt
Text file attached
CAPTCHA.txt
ASKER
I created a separate form as suggested to make it work. I think it was the easiest thing to do.
Thanks
Thanks
Your form have two buttons, and I supose that both execute different actions. You must isolate the point where you call the captcha and make that it doesn't execute when action from unsubscribe button is called.
If the captcha is launched on the form onsubmit event you should detect on client code wich button has been clicked before submitting and cancel the captcha execution.