Been struggling with this for a couple days now. Here's the set up - I have a parent page "support.php" there are tabs, and when you click a tab it brings in the appropriate form via ajax. (the relevant code for each section:)
form input's on the AJAX page
<input type="text" class="numbers" name="captchaImage" id="SupportNumbers" size="6" value="" readonly>
<input type="text" class="numbers" name="SupportMath" id="SupportMath" size="6" maxlength="6" tabindex="9">
The parent page - support.php calls for "validation.js" which is my jQuery.validate script.
...
SupportMath: {
required: true,
equal: "<?php echo $randomNumTotal; ?>"
}
There is a .get command on the parent page for a file "random.php"
$.get('PHP/random.php', function (data){
$("#SupportNumbers").val(data);
});
<?php
$randomNum = rand(0,9);
$randomNum2 = rand(0,9);
echo $randomNum ."+". $randomNum2;
$randomNumTotal = $randomNum + $randomNum2;
?>
which generates two random numbers so you can add them together. The validation checks to make sure the two numbers that are generated are added correctly. I just can't seem to get all these pieces to use the same numbers, i can get the text box "SupportNumbers" to populate with two random numbers say "2 + 5" but when I enter "7" into "#SupportMath" it displays the error msg. It should be $randomNumTotal but I can't get that to the page, and have the validation script check against that. HELP.
I realize this is clear as mud so ill try and explain more I have 5 forms on my support page. To reduce the chaos, I have them in a vertical tab set. I don't want my js validation script on the page and I don't want all 5 forms hidden/displayed on the page due to some issues we've had with some bots. So my solution was to bring in the forms with AJAX (done) and just link to the validation script (done) all is good except for our "random math captcha" I can put it in a file and use the ".get" command to populate the box that holds the two random math questions, but can't get the answer to validate. Hope this helps, code below.