close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

CAPTCHA validation not working and form values not being remembered

Thread began 3/16/2011 5:45 pm by YellowCircleWeb | Last modified 3/17/2011 3:45 pm by Jason Byrnes | 4041 views | 8 replies |

YellowCircleWeb

CAPTCHA validation not working and form values not being remembered

Hi again,

I'm now having a problem getting the CAPTCHA validation working on my form.
There is already server validation on the page that checks against a duplicate email address and this works fine, however the other validation doesn't.

I have used Form Toolkit to add the captcha field. I then substituted the text box for the captcha code for a spry validation text field with the same id (to include client validation ensuring the field wasn't blank).

I added server validation to check that the value entered in the text box was the same as the session variable that stores the captcha value (making sure I set case-sensitivity to off).

I also added default values for the other fields on the form so that if the captcha validation failed the previously entered values would be remembered (I chosed the validatedentries values for each field).

When I enter an incorrect code the form just re-loads with all fields blank and no validation message is shown. Also, when I enter all details correctly the record doesn't get inserted into the database. Instead the form re-loads with all fields blank.

I've attached my page in a zip file.

Attached Files
website-hosting-competition-with-CAPTCHA.zip
Sign in to reply to this post

Jason ByrnesWebAssist

1) Dont use 2 separate server validation behaviors, use the same one for both validations.


2) in the like entry validation you are using the Security_Code_1 element from the validated entries collection on the bindings panel, this will only be given a value when validation fails. Instead you should use the Security_Code_1 element from the form collection on the bindings panel.

Sign in to reply to this post

YellowCircleWeb

Thank you Jason. I will give that a go.

Sign in to reply to this post

YellowCircleWeb

Updated, as advised. Still not working properly

I've made the changes to the code that you suggested Jason. My form will now insert the record again if everything is correct, but the server validation on the CAPTCHA field still doesn't display the error message when the user enters an incorrect code and the previously entered values in the other fields still do not display.

I've attached my revised file in zip format.

Attached Files
website-hosting-competition-single-validation.zip
Sign in to reply to this post

Jason ByrnesWebAssist

you had bound the default values for the form elements when you had 2 sserver validation behavior on the page. You need to rebind the default values to the validated entries now that you have removed one of them.



the capthcha error is not showing because it is inside the spry element, so will only show if spry validation fails.

change

php:
<span id="sprytextfield4">

        <label for="Security_Code_1">Enter the code: </label>
        <input type="text" name="Security_Code_1" id="Security_Code_1" />
      <span class="textfieldRequiredMsg">You must enter a matching code.</span>
      
      <?php
if (ValidatedField('websitehostingcompetition_521','websitehostingcompetition_521'))  {
  if ((
strpos((",".ValidatedField("websitehostingcompetition_521","websitehostingcompetition_521").","), "," "2" ",") !== false || "2" == ""))  {
    if (!(
false))  {
?>
        <span class="textfieldRequiredMsg">Error! The codes do not match</span>
        <?php //WAFV_Conditional website-hosting-competition.php websitehostingcompetition_521(2:)
    
}
  }
}
?>
      </span>




to:

php:
<span id="sprytextfield4">

        <label for="Security_Code_1">Enter the code: </label>
        <input type="text" name="Security_Code_1" id="Security_Code_1" />
      <span class="textfieldRequiredMsg">You must enter a matching code.</span>
      </span>
      <?php
if (ValidatedField('websitehostingcompetition_521','websitehostingcompetition_521'))  {
  if ((
strpos((",".ValidatedField("websitehostingcompetition_521","websitehostingcompetition_521").","), "," "2" ",") !== false || "2" == ""))  {
    if (!(
false))  {
?>
        <span class="textfieldRequiredMsg">Error! The codes do not match</span>
        <?php //WAFV_Conditional website-hosting-competition.php websitehostingcompetition_521(2:)
    
}
  }
}
?>
Sign in to reply to this post

YellowCircleWeb

Thanks for the help, but it's still not working.

I removed the dynamic values from each of the text boxes, saved the page and then added the binding again. I copied and pasted your amended code into the web page at the location indicated but entering an invalid code simply re-loads the page and each text box is empty.

The page does recognise the error because if I enter all details correctly the form submits and the information is added into my database. It's simply not retaining the previously entered values or displaying the captcha error message.

I've attached the updated version of the file with the amendments you suggested included. Would you help me again please?

Attached Files
website-hosting-competition-jasons-changes-inc.zip
Sign in to reply to this post

Jason ByrnesWebAssist

the code for the validated entries is not correct.

for example:
value="<?php echo(ValidatedField("websitehostingcompetition","Name")) ?>"


should be:
value="<?php echo(ValidatedField("websitehostingcompetition_521","Name")) ?>"



does the email validation message display?


perhaps try changing:
<span class="textfieldRequiredMsg">Error! The codes do not match</span>

to:
Error! The codes do not match


if you continue having problems, please post a link where i can see the issue.

Sign in to reply to this post

YellowCircleWeb

It works!!!!

Thank you, thank you Jason.

It's working now. I really appreciate your help with this. One last question though - you said that my validated entries code was incorrect and you were right about this it should have been <?php echo(ValidatedField("websitehostingcompetition_521 ","Name")) ?> as you stated. However, when the _521 bit does not get added when choosing the validated entries field values from the bindings panel - I had to manually type that in. Is this a bug in Validation Toolkit or was it something to do with me originally having two separate server validation server behaviours on the page??

Sign in to reply to this post

Jason ByrnesWebAssist

I think it has to do with originally having 2 validation behaviors on the page, I have not been able to reproduce the problem though.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...