I have a text box with a number outside of it that I initially set at 7 via script. When I type in the text box I want the number to decrease, when I delete characters I want it to increase. The script I have now decreases the number as expected, but when I delete it still decreases. When there is no characters left in the field and I press delete the number increases. Can someone put me on the right track? Thanks.
Here's what I have:
var origCnt = 7; $('#cntEngDesg_insert').html(origCnt); $('#txtEngDesg_insert').keyup(function () { var currentlen = $('#txtEngDesg_insert').val().length; if (currentlen++) { origCnt--; $('#cntEngDesg_insert').html(origCnt); } else if (currentlen--) { origCnt++; $('#cntEngDesg_insert').html(origCnt); } });