我想在输入字段中接受一个URL。但我不关心https://或https://。我只想删除此验证。但它应该只接受一个URL。
例如www.example.com或……
在这里,我为我的问题做了答案。我正在使用正则表达式进行验证。
<input pattern="^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$" placeholder="Find your website ranking... Eg - site.com" class="form-control" name="url" oninvalid="setCustomValidity('Please Enter URL.')" onchange="try{setCustomValidity('')}catch(e){}" >
URL Cheker Regex - ^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$
我正在使用bellow javascript更改验证消息 -
oninvalid="setCustomValidity('Please Enter URL.')" onchange="try{setCustomValidity('')}catch(e){}"