regex - Jquery Validation to validate URL -


i trying validate url in jquery regular expression using below code. working fine http://www , https://www

var myvariable = "http://www.example.com/2013/05/test-page-url-512-518.html";  if(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/|www\.)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/.test(myvariable)){     alert("valid url"); } else {     alert("invalid url"); } 

edit:-

above code work validate url. time requirement validate http://www , https://www

your pattern defined as

^(http:\/\/|someting else

thus any-urls begin "http://" validated.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -