JSFiddle - React, Tailwind, and code Playground

HTML

Ente URL : <input type="text" value="" name="my_url" id="my_url" />
<input type="button" onclick="javascript:match_url();" value="Check URl" />

JavaScript

function match_url()
{
    var url = document.getElementById('my_url').value;
//var url = "http://www.example.com";
var url_regx = /^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/;
    
if(url.match(url_regx))
{
  alert("matched");
}
else
{
  alert("unmatched");
}
}