我想檢查一個URL是否來自同一個域與jQuery驗證addMethod。jQuery驗證addMethod - 檢查是否相同的域
這裏就是我有這麼遠,但它似乎並不奏效:
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
}
}
});
那麼它似乎是工作,因爲它應該。 我如何添加選項'www。'在那裏? – Ricky 2010-06-16 00:36:11