AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Saturday, 25 June 2016

How to Validate URL without or with http(s) in JavaScript?

In this article I am going to discuss How to validate URL without or with http(s) in JavaScript? Please check below java script code.
<html xmlns="">
<title>How to Validate URL without or with http(s) in JavaScript?</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$( document ).ready(function() {
  $('#btnValidate').click(function() {
    var txt = $('#txturl').val();
    var re = /(http(s)?:\\)?([\w-]+\.)+[\w-]+[.com|.in|.org]+(\[\?%&=]*)?/
    if (re.test(txt)) {
    alert('Valid URL')
    else {
     alert('Please enter valid URL');
     return false;
 Input URL :<input type="text" id="txturl" />
<input type="button" id="btnValidate" value="Validate" />

Test Cases:
1- aspbucket
Result: Fail

Result: Pass



   1 comment :

  1. Adding in the fun is a single-site progressive that resets at $10,000. And increasingly, the psychological and technical techniques originally constructed for slot machines — together with reward schedules and tracking techniques — have discovered admirers in Silicon Valley. I agree with everyone 메이저사이트 who contributed to the article, which states the RNG is not RNG. truly have} proven over 12 years of enjoying in} land-based slots in the USA that slot machines aren't random, as individuals and others claiming to be experts declare. I study patterns on several of} hundred slot machine plays, enjoying in} every week. When enjoying in} slot machines, truly have} retained patterns over the years.


  • Popular Posts
  • Comments