best way to validate website field
Posted: Fri Jun 25, 2010 7:26 am
hi, i have a form with an input to type your website, and i have this pregmatch to validate it:
but turns out that it will only accept results with http:// in front of it, and 99% of people who register their website address wont put http:// .
what would be the best way to validate website?
i need to keep the same format on all registered websites inside my database, cuz they will be a link in user's profile, and i cant have like
or
any thoughts about that?
thanks in advance!
Code: Select all
preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $validsite)what would be the best way to validate website?
i need to keep the same format on all registered websites inside my database, cuz they will be a link in user's profile, and i cant have like
Code: Select all
<a href="www.user.com">Code: Select all
<a href="http://http://www.user.com">thanks in advance!