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
Post a Comment