title: Javascript regular expression for URL validation
body: <p>I want the regular expression to validate the URL with below condition,</p>
  
  <ol>
  <li>It should start with http or https</li>
  <li>It should end with the valid domain.
  Ex: .com or .in but after the . can have any string. Specially, check whether the <code>.</code> is there and there is a string following the <code>.</code>.</li>
  </ol>
  
  <p>Valid URL: <code>http://www.cnn.com</code></p>
  
  <p>Invalid URLS:</p>
  
  <pre><code>htt://www.yahoo.com
  http://www.yahoo.
  http://www.yahoo
  </code></pre>
  
  <p>I have compose the regular expression as below.</p>
  
  <pre><code>/^(http|https):\/\/[-a-zA-Z0-9+&amp;@#/%?=~_|!:,;]+([\-\.]{1}[-a-zA-Z0-9+&amp;@#/%?=~_|]+)*\.[a-zA-Z]{2,5}(:[0-9]{1,5})?(\/.*)?$/
  </code></pre>
  
  <p>It worked fine for most of the scenarios.</p>
  
  <p>But if I enter <code>http://www.yahoo</code> didn't validate correctly, but If I enter <code>http://www.google</code> it throws the validation error.</p>
  
  <p>Can anybody please help me to resolve this issue?</p>