javascript character count and remaining characters - Web Development and Web Design Codes

Latest

Saturday, February 17, 2018

javascript character count and remaining characters

JavaScript textarea character count with limit

javascript character count and remaining characters
javascript character count and remaining characters

Hi friends today we will learn JavaScript character count and remaining Character in textarea ..use the below codes to implement 
JavaScript character count and remaining Character in textarea

1. index.html
<html>
<head>
<title>javascript character count and remaining characters</title>
<style>
  #content{
    width:500px;
	margin:auto;
  }
  textarea{
    border-radius:4px;
	font-size:18px;
  }
  input[type=text]{
    padding:4px;
	border-radius:4px;
  }
</style>
<script type="text/javascript">
var count = "125";
//You can Increase The Limit Example: var count = "175";
function limiter(){
var tex = document.Thisform.comment.value;
var len = tex.length;
if(len > count){
tex = tex.substring(0,count);
document.Thisform.comment.value =tex;
return false;
}
document.Thisform.limit.value = count-len;
}
</script>
</head>
<div id="content">
<h3>javascript character count and remaining characters</h3>
<form name="Thisform">
<div><textarea name="comment" rows="10" cols="40" onkeyup="limiter()"></textarea></div>
<script type="text/javascript">
document.write("<input type=text name=limit size=4 readonly value="+count+">Chracters Left");
</script>
</form>
</div>

</html>

That's it friends how to implement JavaScript character count and remaining characters ..
Stay with us for more codes ..Thank You..

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.