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

Editable RadAutoComleteBox input area max length

3 Answers 147 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Sudhanshu
Top achievements
Rank 1
Sudhanshu asked on 03 Jan 2014, 11:14 AM
   How to set max length of input area for editable RadAutoComleteBox  so that use can not enter more than specified max length?

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 03 Jan 2014, 03:01 PM
Hi Sudhanshu,

I guess you want to limit the entries into the RadAutoCompleteBox, you can try handling the OnClientEntryAdding event in this way:

ASPX:
<telerik:RadAutoCompleteBox ID="RadAutoCompleteBox2" runat="server" OnClientEntryAdding="OnClientEntryAddingHandler". . . .>
</telerik:RadAutoCompleteBox>

JS:
<script type="text/javascript">
    function OnClientEntryAddingHandler(sender, eventArgs) {
        if (sender.get_entries().get_count() > 0) {
            eventArgs.set_cancel(true);
            alert("You can select only one entry");
        }
    }    
</script>

Thanks,
Princy
0
Sudhanshu
Top achievements
Rank 1
answered on 04 Jan 2014, 08:00 AM
Hi Princy,
             thanks for reply, But I want user can not enter character after specific length(Eg. 20) in RadAutoCompleteBox.
0
Princy
Top achievements
Rank 2
answered on 04 Jan 2014, 09:11 AM
Hi Sudhanshu,

Please try the following JavaScript to set the maximumLength for RadAutoCompleteBox.

JavaScript:
<script type="text/javascript">
    var maxLength = 20;
    $(".racInput").keyup(function () {
        var text = $(this).val();
        var textLength = text.length;
        if (textLength > maxLength) {
            $(this).val(text.substring(0, (maxLength)));
            alert("Sorry, you only " + maxLength + " characters are allowed");
        }
    });
</script>

Hope this will helps you.
Thanks,
Princy.

Tags
AutoCompleteBox
Asked by
Sudhanshu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Sudhanshu
Top achievements
Rank 1
Share this question
or