yes u can do.
here is an example for the same using custom validator
this is the javascript, i have used the script to check if my text entered is of length 5, u can write ur alert method inside the else loop.
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function checkNAME(Source,args)
{
var a = document.getElementById("TextBox1").value;
if(a.length == 5){
args.IsValid = true;
}
else{
args.IsValid = false;
}
}
</script>
</head>
This is the asp control and its property
<asp:CustomValidator ID="CustomValidator1" runat="server"
ErrorMessage="CustomValidator" ClientValidationFunction="checkNAME"
ControlToValidate="TextBox1"></asp:CustomValidator>
ClientValidationFunction wil call the javascript wher u can check for the function u want and display the message.