<%@ Page Language="VB" %>
<script runat="server">
sub Submit(Sender as Object, e as EventArgs)
if Page.IsValid then
lblMessage.Text = "It's all good!"
end if
end sub
sub ValidateThis(Sender as Object, args as _
ServerValidateEventArgs)
if len(args.Value) < 8 then
args.IsValid = false
else
args.IsValid = true
end if
end sub
</script>
<script language="JavaScript">
function validateLength( oSrc, txtValue ){
var retValue = true;
if(txtValue.length < 8){
retValue = false;
}
return retValue
}
</script>
<html><body>
<form runat="server">
<asp:Label id="lblMessage" runat="server" />
<table>
<tr>
<td valign="top">Username:</td>
<td valign="top">
<asp:Textbox id="tbUserName" runat="server"
/><br>
<asp:CustomValidator runat="server"
OnServerValidate="ValidateThis"
OnClientValiate="validateLength"
Display="Dynamic"
ControlToValidate="tbUserName"
ErrorMessage="The username must be 8 characters or longer"/>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<ASP:Button id="tbSubmit" runat="server"
OnClick="Submit"
text="Submit" />
</td>
</tr>
</table>
</form>
</body></html>
|