In the form (addition highlighted):
Code:
<?php $a = rand() % 2; $b = rand() % 3; $c = $a + $b; ?>
<input type="hidden" name="security" value="<?php echo "$c"; ?>">
<label class="security">
<input type="text" value="<?php echo "Security question: $a + $b =";?>">
<span class="error">*This is not a valid response.</span> <span class="empty">*This field is required.</span>
</label>
In the script, change highlighted:
Code:
rx:{
".name":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
".state":{rx:/^[a-zA-Z'][a-zA-Z-' ]+[a-zA-Z']?$/,target:'input'},
".email":{rx:/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i,target:'input'},
".security":{rx:new RegExp('^' + $('[name="security"]',th).val() + '$')
,target:'input'},
".fax":{rx:/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/,target:'input'},
".message":{rx:/.{20}/,target:'textarea'}
},
This will require the response to be the correct response and only the correct response.
I think it would be nice, if the incorrect response is given, that the original content (in this case the math problem) should be shown again on focus or even right away. But I'm not sure how to do either of those . . . yet.
Bookmarks