jQuery Validation addMethod - Check if same domain
Posted
by Ricky
on Stack Overflow
See other posts from Stack Overflow
or by Ricky
Published on 2010-06-16T00:17:45Z
Indexed on
2010/06/16
0:22 UTC
Read the original article
Hit count: 457
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
}
}
});
© Stack Overflow or respective owner