In asp.net using jQuery and Javascript you can do it by following code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" EnableViewState="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof String.prototype.startsWith != 'function') {
String.prototype.startsWith = function (prefix) {
return this.slice(0, prefix.length) == prefix;
};
}
function ValidateUrl() {
var url = $('#<%=txtUrl.ClientID %>').val();
if (url.startsWith("http:\\") || url.startsWith("https:\\")) {
alert(url);
return true;
}
else {
alert("it is not valid");
return false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtUrl" runat="server"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" onClientClick="return ValidateUrl()" />
</div>
</form>
</body>
</html>