I want to know if it's possible to show result of an entityreference autocomplete only when the user enters 5 or 6 characters.


One way to do it is create your own custom autocomplete (a good example is here) in your custom module. Then within your custom autocomplete function check if the submitted autocomplete string is 5-6 chars long then execute the search, like so (using the example from the tutorial above):

function demo_autocomplete($text) {
  if (strlen($text) > 5) {
  // execute your code here:
    $results = array();
    ... etc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.