I want a simple as possible regex to check the format of my form submission URL string, I don't care whether is an actual real working URL, just that it be in proper URL format and, IF POSSIBLE add someting so that the URL characters are the only charactrers entered in the field:
so it would be an err msg prompt for legit users to enter their link in the proper format;
On the uther hand, it should not allow spammers to enter tons of text in the url field.
I have used the following regex to chewck that there are characters supplied in addition to the http:// value in the form field, and it works with simple urls but it does not work with urls such as
http://somesubdomain-somesitename.or g/somepagename.ht m
if ($FORM{'url'} eq 'http://' || $FORM{'url'} !~ /^(f|ht)tp:\/\/\w+\.\w+/) {
&no_url;
}
so it would be an err msg prompt for legit users to enter their link in the proper format;
On the uther hand, it should not allow spammers to enter tons of text in the url field.
I have used the following regex to chewck that there are characters supplied in addition to the http:// value in the form field, and it works with simple urls but it does not work with urls such as
http://somesubdomain-somesitename.or g/somepagename.ht m
if ($FORM{'url'} eq 'http://' || $FORM{'url'} !~ /^(f|ht)tp:\/\/\w+\.\w+/) {
&no_url;
}
Comment