You can use javascript for that....
Take this example
<script type="text/javascript">
function validateForm()
{
var name=document.getElementById("<%=txtname.ClientID%>").value.trim();
var contact=document.getElementById("<%=txt_contact_no.ClientID%>").value.trim();
var email=document.getElementById("<%=txt_email.ClientID%>").value.trim();
var comments=document.getElementById("<%=txt_coments.ClientID%>").value.trim();
if(name=="")
{
alert("Name must not be blank... ");
document.getElementById("<%=txtname.ClientID%>").focus();
return false;
}
if(email=="")
{
alert("Email Address must not be blank... ");
document.getElementById("<%=txt_email.ClientID%>").focus();
return false;
}
if(email != "")
{
var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
var compare=email.match(emailPat);
if(compare == null)
{
alert("Invalid Email address ! Please try again!!");
document.getElementById("<%=txt_email.ClientID %>").value ="";
document.getElementById("<%=txt_email.ClientID %>").focus();
return false;
}
}
if(contact=="")
{
alert("Contact Number must not be blank...");
document.getElementById("<%=txt_contact_no.ClientID%>").focus();
return false;
}
if(comments=="")
{
alert("Comments must not be blank...");
document.getElementById("<%=txt_coments.ClientID%>").focus();
return false;
}
if(!isNaN(name))
{
alert("Numbers and special Characters are not allowed in Name field...");
document.getElementById("<%=txtname.ClientID%>").focus();
return false;
}
if(isNaN(contact))
{
alert("Only numbers are allowed...");
document.getElementById("<%=txt_contact_no.ClientID%>").focus();
return false;
}
}
function textboxMultilineMaxNumber(txt,maxLen)
{
if(txt.value.length>50)
{
return false;
}
}
function NumberOnly(txt,value)
{
var AsciiValue=event.keyCode
if((AsciiValue>=48 && AsciiValue<=57) || (AsciiValue==8 || AsciiValue==127))
{
if(txt.value.lenghh>10)
{
return false;
}
event.returnValue=true;
}
else
event.returnValue=false;
}
</script>
and put this script onClientClick of Button