- Forums
- Javascipt
- Javascript Check Textarea Length Of Characters
if you want to know how you can count the number of charters submitted in a textarea form, this short script will show you how you can. its very simple. the main component here is the field.value.length you can find out how long it is [2231], Last Updated: Mon Jun 24, 2024
Webune Support
Mon Aug 02, 2010
1 Comments
522 Visits
if you want to know how you can count the number of charters submitted in a textarea form, this short script will show you how you can. its very simple. the main component here is the Field.value.length
if you are using windows, open a blank notepad, copy and paste the following code:
<!--
############## CREATED BY WWW.WEBUNE.COM ###############
############## COPYRIGHT UGN/GPL 2010 #################
############# PLEASE DO NOT REMOVE THIS ###############
-->
<p>This small script shows you how to get the javascript value in a web form.<br /></p>
<script type="text/javascript">
function alertselected(){
var Field = document.getElementById('sample');
alert('selectedIndex = ' + Field.checked + ' \n value = ' + Field.value + ' \n type = ' + Field.type + ' \n length = ' + Field.value.length );
}
</script>
<form id="someform">
agree to terms:
<textarea type="checkbox" id="sample"></textarea><br />
<input type="button" onClick="alertselected()" value="alert" />
</form>
<p><img src="http://www.webune.com/images/headers/default_logo.jpg" /></p>
<p>Script Created by www.<a href="http://www.webune.com">Webune.com</a></p>
2. now save the file as
form-textarea.html - after you have saved it, open it with your browser and see it action. it will tell you how many character you entered in the textarea field
DEMO
hope that helps
form-textarea.html