Skip to content

Instantly share code, notes, and snippets.

@codingwithsara
Created August 3, 2019 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingwithsara/f903874eaed6177b75e3c2aff3d9bb59 to your computer and use it in GitHub Desktop.
Save codingwithsara/f903874eaed6177b75e3c2aff3d9bb59 to your computer and use it in GitHub Desktop.
JavaScript Text Counter
<script>
function count_up(obj) {
document.getElementById('count1').innerHTML = obj.value.length;
}
function count_down(obj) {
var element = document.getElementById('count2');
element.innerHTML = 30 - obj.value.length;
if (30 - obj.value.length < 0) {
element.style.color = 'red';
} else {
element.style.color = 'grey';
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment