How can I make my character countdown reset back to 150 when my submit button is clicked? Right now I have a input text box that you type in and it counts down how many characters you have left and then when you want to submit it, you click the submit button and it adds it to a table. But the problem is that the number stays the same and doesn't reset back to 150 until you start typing in the box again. I want it to automatically reset to 150 when you click the submit button. What will I need to add to my code?
http://jsfiddle.net/julianbuscema/qv0zd8pv/
$(document).ready(function(){
var left = 150
$('#text_counter').text(left);
$('#status').keyup(function () {
left = 150 - $(this).val().length;
if(left < 0){
$('#text_counter').addClass("overlimit");
}
if(left >= 0){
$('#text_counter').removeClass("overlimit");
}
$('#text_counter').text(left);
});
});
just re declare it