Show Tooltip or Invalid Icon on MaxLength?

2 posts, 0 answers
  1. Justavian
    Justavian avatar
    23 posts
    Member since:
    Aug 2010

    Posted 12 Aug 2012 Link to this post

    What's the best way to notify the user that they've arrived at the maximum length supported by a particular field?  Will i have to use a key up function and test the length, or is there some alternate method i might use?  It doesn't appear that there is anything built in - is there something i missed?

    -RP
  2. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 15 Aug 2012 Link to this post

    Hello Rich,

    Please try the following approach:
      mark-up:
    <telerik:RadTextBox ID="RadTextBox1" runat="server" MaxLength="2"
    ClientEvents-OnKeyPress="keyPressed"></telerik:RadTextBox>
      JavaScript:
    function keyPressed(sender, args) {
        var currentText = sender.get_textBoxValue();
        setTimeout(checkText, 1, [currentText, sender.get_id()])
    }
    function checkText(arguments) {
        var oldText = arguments[0];
        var newText = $find(arguments[1]).get_textBoxValue();
        if (oldText == newText) {
            alert("Max length reached");
        }
    }

    In addition, you could use a more user-friendly message form control instead of alert, for example RadWindow, RadTooltip, RadMenu, etc.

    I hope this will prove helpful.

    All the best,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top