URL Validation REGEX - URL just valid with http://

后端 未结 5 1151
梦谈多话
梦谈多话 2020-12-14 17:50

How it works

I have an input field to enter the URL of a Website and i wanna check it and if the URL is OK i will give the inputfield a class(\"vali

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-14 18:39

    Remove the |www\.?

    ^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
    

提交回复
热议问题