I found lots of url validation method in this website and also in others. But i can not find the exact one that is required for my project. Here is what i need.
<form name="example" value="">
<input type='text' name='link' />
<input type="submit" name="submit" id="submit" value="" />
</form>
Now if someone type a link in the text field then i have to check whether the link is valid or not. Valid link will be like
1. http://www.example.com
2. www.example.com
3. example.com
4. (some space) then one of the three links above
5. one of the three links above then some space
These are the valid formats. Anything else is typed in the text field should give output invalid link
I require the solution both in javascript and PHP.