Answered by:
Search for word

Question
-
User861911889 posted
Hi
I have weird problem. I am using JQuery autocomplete functionality. Now the value that put me in trouble is 'TP 0042', I want to see 'TP 0042' as option when I will search for
'TP 0042'(with space) or 'TP0042'(without space).
Please please please help me.
Friday, January 15, 2016 11:39 AM
Answers
-
User632428103 posted
Hello 666 => the evil :)
is it a jquery autocomplete or this control is a part of ajax control toolkit extender ?
i'm not an expert but normally if you query is the % in the search method all record with or without space must be return ..
Hope this help
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, January 15, 2016 2:29 PM
All replies
-
User632428103 posted
Hello 666 => the evil :)
is it a jquery autocomplete or this control is a part of ajax control toolkit extender ?
i'm not an expert but normally if you query is the % in the search method all record with or without space must be return ..
Hope this help
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, January 15, 2016 2:29 PM -
User-698989805 posted
Please refer to this link and you will get the solution:
http://www.aspdotnet-suresh.com/2012/07/jquery-autocomplete-textbox-with.html
There is a change in jQuery. Replace this with the following code:
<script type="text/javascript"> $(document).ready(function() { SearchText(); }); function SearchText() { $("#txtSearch").autocomplete({ source: function(request, response) { $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "AutoCompletewithMultipleSelection.aspx/GetAutoCompleteData", data: "{'username':'" + extractLast(request.term) + "'}", dataType: "json", success: function(data) { response(data.d); }, error: function(result) { alert("Error"); } }); }, focus: function() { // prevent value inserted on focus return false; }, select: function(event, ui) { var terms = split(this.value); // remove the current input terms.pop(); // add the selected item terms.push(ui.item.value); // add placeholder to get the comma-and-space at the end terms.push(", "); this.value = terms.join(" "); return false; } }); $("#txtSearch").bind("keydown", function(event) { if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete").menu.active) { event.preventDefault(); } }) function split(val) { return val.split(""); //This section specifies to accept the word with space } function extractLast(term) { return split(term).pop(); } } </script>
Friday, January 15, 2016 3:08 PM