J
jwcarlton
This is a tricky one for me. I'm validating a form, and want to check
if a field entered is a legitimate website address. I don't
necessarily need to ensure that the site works (I can do that later),
but I do want to see if what's entered is a likely URL.
I'm currently just checking to see if it begins with "http", but
that's not so great; a less-savvy person might enter
"www.example.com", or even "example.com", and get an error that it's
not a legitimate link.
I've thought about testing to see if it contains at least 1 "." (since
all website addresses would, I think), but that's pretty vague; a less-
savvy person might enter their email address, and it would go through.
I guess that I could also check for an "@", but I can't help but
wonder if there's a smarter / smoother option?
if a field entered is a legitimate website address. I don't
necessarily need to ensure that the site works (I can do that later),
but I do want to see if what's entered is a likely URL.
I'm currently just checking to see if it begins with "http", but
that's not so great; a less-savvy person might enter
"www.example.com", or even "example.com", and get an error that it's
not a legitimate link.
I've thought about testing to see if it contains at least 1 "." (since
all website addresses would, I think), but that's pretty vague; a less-
savvy person might enter their email address, and it would go through.
I guess that I could also check for an "@", but I can't help but
wonder if there's a smarter / smoother option?