I'm trying to check whether a URL is from the same domain with jQuery Validation addMethod.
Here's what i got so far, but it doesn't seem to be working:
jQuery.validator.addMethod("domain", function(value, element) {
return this.optional(element) || /^http:\/\/testsite.com/.test(value);
}, "The URL doesn't match.");
$("#url_form").validate({
rules: {
url: {
required: true,
url: true,
domain : true
}
}
});