views:

89

answers:

0

Hello, I need a little help adding a custom addMethod to my validation rules. Here is where it explains how, but I'm still stuck http://docs.jquery.com/Plugins/Validation/Validator/addMethod#namemethodmessage any help would be awesome! I want to add the ability to prevent URL's (www or http://) from being entered in the textarea field (AKA "comment"). Thanks for any help!

Here are my current set of validation rules...

<script type="text/javascript">
 $.validator.methods.equal = function(value, element, param) {
  return value == param;
 };
 $(document).ready(function(){
  $("#contactform").validate({
    rules: {
     name: "required",
     email: {
     required: true,
     email: true
     },
     comment: {
     required: true,
     minlength: 5
     },
     captcha: {
      equal: 4
     }
    },
    messages: {
     email: "",
     name: "",
     comment: "",
     captcha: ""
    }
   });
 });
</script>

Here are my current set of PHP cleaning rules. I just need to change the syntax a little probably but dont know how.

// Clean Comments
if (get_magic_quotes_gpc()) {
 $comment = stripslashes( $comment );
}
if (preg_match("{link=}", $comment) || preg_match("{url=}", $comment) || preg_match("{http://}", $comment))
{
    header( "Location: $errorurl" );
 exit ;
}