Regular expression for validating url that starts with http: in JavaScript such as https://www.authorcode.com.
<html> <head> <script type="text/javascript"> var reg = /^(ht|f)tp(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$/; function URLValidation(url) { var OK = reg.exec(url.value); if (!OK) window.alert("URL isn't valid"); else window.alert("URL is valid"); } </script> </head> <body> <p>Enter your url address then press Enter.</p> <form action=""> <input name="txturl" onchange="URLValidation(this);"> </form> </body> </html>
URIs (or URLs) are valid without the scheme specified. The scheme precedes //, e.g. //authorcode.com is as valid as http://authorcode.com