Please refer below sample.
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function ValidURL(str) {
var regex = /(http[s]?:\/\/)(www[\w]?\.)[\w]*\.[\w]{2,3}(\.[\w]{2})?$/;
if (!regex.test(str)) {
alert("Please enter valid URL.");
return false;
} else {
alert("Valid URL.");
return true;
}
}
</script>
</head>
<body>
<div>
<input type="text" id="txtUrl" onblur="ValidURL(this.value)" />
</div>
</body>
</html>
Demo
I hope this will help you out.