2011-12-01 56 views
2
<script type="text/javascript"> 


    $(function() { 
     $("#searchTerm").autocomplete({ 
      //appendTo:"#abc", 
      // position: { my : "right top", at: "right bottom" }, 
      source: "home/search", 
      minLength: 1, 

      autoFocus: true, 
      select: function (event, ui) { 
       if (ui.item) { 
        $("#searchTerm").val(ui.item.value); 
        $("form").submit(); 
       } 
       else { alert("abc")} 
      } 

     }); 
    }); 
</script> 

我嘗試了幾件事情,但不知何故我不能破解這個簡單的事情。在此先感謝想要添加警告如果searchTerm長度== 0

回答

0

如何:

if($.trim($("#searchTerm").val()).length === 0) { 
    alert("empty"); 
} 
0

如果.value的是一個字符串的話..

if (ui.item.value.length == 0) 
相關問題