0

I am using JQuery TokenInput instead of auto search. If I press space bar multiple times, then by using back space, remove all spaces and in result it shows me a list which contains all values of that field.

How can I restrict on search for spaces?

I written like this:

     $("#org_id").tokenInput("/org/search_org_by_token_input.json",{
          crossDomain: false,
          tokenLimit: 1,
          minChars:1,
          theme: 'facebook',

      });
Buh Buh
  • 7,443
  • 1
  • 34
  • 61
unnati patil
  • 1,601
  • 2
  • 13
  • 12

1 Answers1

0

You would need to go in to the library code, and modify the .keydown part of var input_box. (Line 276 in my version.)

There is a huge switch statement which deals with all the special keys, you'll want to add a case for KEY.SPACE. (It's already included in the enum, so you can just use that option straight off.)

If you just want to ignore all spaces altogether, then you could add something like the following. If you're looking for different functionality (such as only ignoring spaces as a first input character) then obviously you'll need to develop it further)

case KEY.SPACE:
 event.stopPropagation();
 event.preventDefault();
 break;

The above is only theoretical/untested and may need debugging!

Chris
  • 5,882
  • 2
  • 32
  • 57
  • Hey, thanks. I try this. It does not allow to enter space. So it can be a solution. But then problem is that if I want to add space in token input, it does not allow for that also. – unnati patil Jul 04 '13 at 11:23
  • Can you explain to me exactly the activity you want? Do you just want to disallow 'space' to be the first character of a string, and then to be valid at any other point? – Chris Jul 04 '13 at 12:45