you can do it using HTML5 and jQuery. Please check 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">
function CheckValue() {
var userName = $("#userName").val();
if (userName == '')
{
alert('user Name is empty');
}
else
{
alert(userName);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="text" id="userName" name="userName" placeholder="Username"><br>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="CheckValue()" />
</div>
</form>
</body>
</html>