How to use CustomValidator in aspx page?

The CustomValidator control allows you to write a method to handle the validation of the value entered in aspx page and you can use this in this way:

<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Sms length is exceeding over 160." ClientValidationFunction="validateLength" ControlToValidate="txtSmsMessage" SetFocusOnError="True" ValidationGroup="add">*</asp:CustomValidator>

<script language="javascript" type="text/javascript">
function validateLength(oSrc, args)
{
args.IsValid = (args.Value.length < 160);
}
</script>

Tagged , . Bookmark the permalink.

Leave a Reply