I am using the fairly limited features of the spry framework in Dreamweaver to validate forms.
When I get to the textarea, validation is limited to:
required
min char, char count
AND NOT MUCH MORE!
I would like to continue to use the spry framework since it is pervasive inside DW CS4 and seems useful - BUT I need to be able to add functionality.
Specificly I would like to check the textarea for content matching a regx string. To determin if the form is getting hit by a spam bot.
I can do this in PHP, like so;
<?PHP
// Spam Detection code block
// The \b in the pattern indicates a word boundary, so only the distinct
//word "web" is matched, and not a word partial like "webbing" or "cobweb" */
// Check for html and img tags in string
function check($comment) {
// if(ereg('(href=\b|http\b|url=http\b|<a href|<IMG=|<img|img=|scr=|www\b)@i', $comment)) {
if (preg_match('(href=\b|http\b|url\b|http\b|<a href|<IMG=|<img|img\b|scr\b|www\b)i', "$comment")) {
// comment looks dirty, lets put up a bogus thankyou.
echo("<pre>
</pre><center> Thanks <p>We have received your comment and hope you enjoyed visiting our site. <p>To continue browsing, use the links above.</center>");
exit();
}
else{ // comment is clean of URLs
}
}
// End of Spam Detection code block
?>
Is there a way to integrate this code (or similar javascipt) into the Spry library, so I can do this in DW?
Anti spam technologies are a very important part of forms these days.
I hope other people value this request and pipe up about it.
Thanks
-Daniel Hoviss