function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
StarhunterStarhunter 

Enabling search button after entering two characters in search box

I want the search button to be disabled on load of page. Only after the user has entered two characters should the search button be enabled to click. I want to achieve this using jquery,something I am not used to. I googled a bit and came to the following :
<script>
$(document).ready(function(){
              $("#btnDisabled").attr("disabled", true);
}

$('#searchbox').on("keyup", disableaction);

function diableaction()
{
if($("#btnDisabled").val().length>1)
      $("#btnDisabled").attr("disabled", false);
}
</script>

Where searchbox is the id of the apex inputtext field and btnDisabled is that of the command button
The button is not even getting disabled on page load.