A Pen by Terron Johnson on CodePen.
Created
October 16, 2017 17:34
-
-
Save Terron23/4ac2b9a049a323533e851bda76baa8f3 to your computer and use it in GitHub Desktop.
Simple Word Counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container text-center"> | |
<h1>Character Restrictor</h1> | |
<form> | |
<textarea name="count" rows="10" placeholder="Write Here" onkKeyDown="textCounter(this.form.count,this.form.countDisplay);" onKeyUp="textCounter(this.form.count,this.form.countDisplay);"></textarea><br> | |
<input class="text-center" readonly type="text" name="countDisplay" size="20" value="300"> Characters Remaining | |
</form> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var max = 300; | |
function textCounter(x, y) { | |
if(x.value.length > max) { | |
x.value = x.value.substring(0, max); | |
} | |
else { | |
y.value = max - x.value.length; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin-top: 50px; | |
padding-bottom: 50px; | |
background: beige; | |
} | |
textarea { | |
width: 100%; | |
padding: 10px; | |
font-size: 2em; | |
border: solid 8px gray; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment