I have implemented the following validation for URLs:
jQuery.validator.addMethod("urlValidatorJS", function (value, element) {
var regExp = (/^HTTP|HTTP|http(s)?:\/\/(www\.)?[A-Za-z0-9]+([\-\.]{1}[A-Za-z0-9]+)*\.[A-Za-z]{2,40}(:[0-9]{1,40})?(\/.*)?$/);
return this.optional(element) || regExp.test(value);
}, "The URL format is incorrect");
However, I noticed that the validation is allowing invalid URLs such as: http://www.example.com/ %20here.html (URL with space).
Could anyone suggest how to fix this issue in the validation?