Autocomplete textbox woth semicolon-separated value

3 posts, 0 answers
  1. Zakir
    Zakir avatar
    7 posts
    Member since:
    Oct 2013

    Posted 03 Sep 2014 Link to this post


    Im using telerik auto complete textbox.
    when i pastes a semicolon-separated list of entries into RadAutoCompleteBox,
    and on TAB press it returns only last semicolon seperated value into token.

    How to get all semicolon-separated value in to separate tokan?

    Thank You
  2. Dimitar
    Dimitar avatar
    277 posts

    Posted 05 Sep 2014 Link to this post

    Hi Zakir,

    In order to create RadAutoCompleteBox tokens on pasting a semicolon-separated list of entries, you can use the RadAutoCompleteBox OnClientLoad event to register a handler for the "paste" event. This handler should parse the text and create entries. This feature can be achieved with the following javascript:

    var $ = $telerik.$;
    function OnClientLoad(sender) {
        $(".racInput").on("paste", function (e) {
            var $this = $(this);
            setTimeout(function () { //break the callstack to let the event finish
                var text = $this.val();
                var lastChar = text.charAt(text.length - 1);
                var myText = text;
                if (lastChar === ";") {
                    var myText = text.substr(0, text.length - 1);
                var array = myText.split(';')
                for (var i = 0; i < array.length; i++) {
                    var currEntryText = array[i];
                    var entry = new Telerik.Web.UI.AutoCompleteBoxEntry();
            }, 0);

    In the example above, we have covered the cases when the list pasted ends with and without a delimiter.
    You can modify the text processing part of the script to cover the use cases relevant for your scenarios.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
  4. Zakir
    Zakir avatar
    7 posts
    Member since:
    Oct 2013

    Posted 08 Sep 2014 in reply to Dimitar Link to this post

    Hi Dimiltar,

    This is exactly what I want!
    Thank you for your valuable reply. :)
Back to Top