You will want to do the validation on the client and on the server, as you cannot guarantee that the client has JavaScript turned on. The following shows the steps to accomplish this on the client side, as implementing this on the server side should be trivial.
Given a simple div such as the following:
<div id="divErrors" runat="server" style="display: none;">
This should only appear when validation fails.
</div>
Add the following JavaScript to your page:
<script language="javascript" type="text/javascript">
function showErrors() {
if (!Page_IsValid) {
document.getElementById('divErrors').style.display = 'block';
} else {
document.getElementById('divErrors').style.display = 'none';
}
}
</script>
Finally, register a submit script that calls this new showErrors function (in the Page_Load event):
If Not Page.IsPostBack() Then
Dim scriptName As String = "OnSubmitScript"
Dim scriptType As Type = Me.GetType()
Dim script As ClientScriptManager = Page.ClientScript
If Not script.IsOnSubmitStatementRegistered(scriptType, scriptName) Then
script.RegisterOnSubmitStatement(scriptType, _
scriptName, "showErrors();")
End If
End If