I need to disable the button when no value is inserted in the input text
<form>
<div class="form-group">
<p class="description">Please Enter Your Tracking Number.</p>
<input type="text" id="tracking-input" class="input-text full-width" placeholder="Enter your Tracking number(s)"onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
</div>
<br>
<button type="submit" id="register" class="full-width btn-medium">Track</button>
</form>
Have tried this but doesn't work
<script>
function buttonState(){
$("input").each(function(){
$('#register').attr('disabled', 'disabled');
if($(this).val() == "" ) return false;
$('#register').attr('disabled', '');
})
}
$(function(){
$('#register').attr('disabled', 'disabled');
$('input').change(buttonState);
})
</script>