Javascript - Jquery url validator, Jquery custom url validation

Jquery url validator

This script is used to validate url on given textbox. A simple textbox url validator.

 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");
 }
 );

 jQuery.validator.addClassRules ( { domainChk: {domainChk: true} } );
 

The topic on Javascript - Jquery url validator is posted by - Namo

Hope you have enjoyed, Javascript - Jquery url validatorThanks for your time

Tech Bluff