Simple idea to check custom validate in URL validator
This idea is most useful to avoid spam contents and unwanted posts in oursite.
Part 1:
Example validate field inside of form element
in the above sample textbox should contain rel="owner url"(E.g)fancygreetings.com
Part 2:
Example of Custom URL validation in jquery
jQuery.validator.addMethod ("domainChk", function (value, element, params) {
if (this.optional (element) )
return true;
//--- Get the target domain, this will be in the rel attribute.
var requireddomain = $(element).attr ("rel");
var regExp = new RegExp ("^http?://(www.)?" + requireddomain + "/", "i");
var regExp = new RegExp (targDomain);
return regExp.test (value);
},
function errmess (params, element) {
return "This must be a valid URL for " + $(element).attr ("rel");
}
);