CustomValidator

// ASPX (HTML) Part
<asp:CustomValidator ID="cvNotes" runat="server" Display="none" ClientValidationFunction="ValidateStringLength" ControlToValidate="txtSuggestion" ErrorMessage="Your suggestion is exceeding 4000 characters.">*</asp:CustomValidator>
           


// ASPX (Javascript) Part
<script language="javascript" type="text/javascript">
function ValidateStringLength(source, arguments)   
{   
     var slen = arguments.Value.length;   
     // alert(arguments.Value + '\n' + slen);   
     if (slen >= 0 && slen <= 4000){   
         arguments.IsValid = true;   
     } else {   
         arguments.IsValid = false;   
     }   
}  
</script>