Get the box value and rest it from the maxlength you have:
let message = document.getElementById('messageBox').value;
let value = 150;
var length = value - message;
Use the length variable whatever you want.
Here is an example I made time ago to even change its colors and determine with a regular expression if there is blank spaces:
// Reads the text area value.
let message = document.getElementById('messageBox').value;
if((character.length <= 0 || !(/[^\s]/.test(message))) && character.length <= 280){
// Disables submit button.
sumbitStatus(true);
// Sets invisible the message of more than 280 characters.(In case the user select and delete the whole message in one move).
document.querySelector('.advertisement').style.display = "none";
// returns counter to blue color.(In case the user select and delete the whole message in one move).
document.querySelector('.character').style.color = '#1EAEDB';
} else if(character.length >= 281){
// Disables submit button and changes counter to red.
sumbitStatus(true);
document.querySelector('.character').style.color = 'red';
// Set visible the message of more than 280 characters.
document.querySelector('.advertisement').style.display = 'block';
} else{
// Enables Submit button and returns counter to blue color.
sumbitStatus(false);
if(character.length >= 250){
document.querySelector('.character').style.color = 'orange';
// Sets invisible the message of more than 280 characters.
document.querySelector('.advertisement').style.display = "none";
}
else{
document.querySelector('.character').style.color = '#1EAEDB';
// Sets invisible the message of more than 280 characters.
document.querySelector('.advertisement').style.display = "none";
}
}
}