I have added jQuery validation method to have HTTP validation in url field.
Js
jQuery.validator.addMethod("valid_url", function(value, element) {
if(!/^(https?|ftp):\/\/i.test(val))
val = 'http://'+val;
$(elem).val(val);
}
My console throws an
"uninitialized regular expression literal in the next line.
if(!/^(https?|ftp):\/\/i.test(val))
What is my mistake?
source
share