You are viewing limited content. For full access, please sign in.

Question

Question

How to show awesomplete-child only if the length > 0 ?

asked on August 30, 2018

Hi all,

In my Web Form, I have an input with auto-suggestions.

 

I want to see the suggestions only if the field.lenght > 0.

I tried to create the rule using Javascript.

$(document).ready(function () {
  
  	//On affiche les suggestions seulement si on a écrit
  	$(".awesomplete-child").hide();
  		
  	$( "#q72 input" ).keyup(function() {
      	
  		var n = $( "#q72 input" ).val() ;
      	var n = n.length ;
      	if (n > 0)
        {
         	//alert("ok");
          	$(".awesomplete-child").show();
        }
      	else
        {
         $(".awesomplete-child").hide(); 
        }
	});
  })

It works but not properly.

This function $(".awesomplete-child").hide(); (line 3) doesn't work.

When I'm clicking for the first time in my field, I have the suggestions.

 

How can I hide this suggestions at the begining ?

Thanks in advance.

Regards

 

0 0

Answer

SELECTED ANSWER
replied on August 30, 2018

Sorry for the inconveniance, I found how to do.

I just have to hide it when I click in the field

$( "#q72 input" ).click(function() {
    	$(".awesomplete-child").hide();
 })

Thank you.

1 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.