aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Regular Expression(Regex) to Validate URL without http(s) in JavaScript

Sep 14, 2013

Here I will explain regular expression for validating website url with or without http in
JQuery, JavaScript or regex to validate website url with or without http(s)  in JQueryJavaScript

In previous articles I explained
validate email address using JQuery, how to disable or enable all the controls on page using JQuery , validate phone number using JQuery and many articles relating to JQuery, JavaScript. Now I will explain regular expression for validating url with or without http in JQuery, JavaScript.

Regular expression to validate url with or without http

$('#btnValidate').click(function() {
var txt = $('#txturl').val();
var re = /(http(s)?:\\)?([\w-]+\.)+[\w-]+[.com|.in|.org]+(\[\?%&=]*)?/
if (re.test(txt)) {
alert('Valid URL')
If you want to see it in complete example need to write the code like as shown below

<html xmlns="">
<title>Regex for urls with or without http Page</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(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;
Enter URL :<input type="text" id="txturl" />
<input type="button" id="btnValidate" value="Validate" />
Live Demo

Enter URL :      

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Anonymous said...


Anonymous said...


Anonymous said...

It's not working correctly...
check with this - ww.dfg

Mallikarjun said...

Fails for :

Anonymous said...

The regular expression identifies tk ..... as I do. ?

Anonymous said...

If i enter "www.test." it shows valid URL

Anonymous said...

Not working properly ???????????????
Fail to test www.akbible.

Unknown said...

Apparently is a valid url?

Anonymous said... is a valid url

Nagaraju Pattem said...

http:// is this valid url?

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.