PDA

View Full Version : Resolved words count validation



vineet
01-06-2009, 10:39 AM
hi

i need to count the number of words in the text area. if exceeds then give alert.

i m using this validation but this counts the characters not words



<script language="javascript">
function alerty()
{
if(document.myform.w.value.length>5)
{
alert("words limit exceeded");
return false;
}
}
</script>




<textarea rows="15" name="w" cols="45"></textarea>


vineet

jscheuer1
01-06-2009, 11:58 AM
<script type="text/javascript">
function alerty()
{
if(document.myform.w.value.split(' ').length > 5)
{
alert("words limit exceeded");
return false;
}
}
</script>

vineet
01-06-2009, 12:01 PM
<script type="text/javascript">
function alerty()
{
if(document.myform.w.value.split(' ').length > 5)
{
alert("words limit exceeded");
return false;
}
}
</script>


hi john

thanks. it works perfect

vineet