$('#numberbox').keyup(function(){ if ($(this).val() > 100){ alert("No numbers above 100"); $(this).val('100'); } });