This is a migrated thread and some comments may be shown as answers.

Show Tooltip or Invalid Icon on MaxLength?

1 Answer 113 Views
Input
This is a migrated thread and some comments may be shown as answers.
Justavian
Top achievements
Rank 1
Justavian asked on 12 Aug 2012, 02:32 PM
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

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 15 Aug 2012, 11:28 AM
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.
Tags
Input
Asked by
Justavian
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or