Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Textarea Validation


Message #1 by "Richard Lee" <richardlee@l...> on Thu, 18 Oct 2001 12:54:07
 hi richard,
i create a code just try this... i hope it will help you.

here's my code ...........

<h3>Hi corgall you can only input 20 character</h3>
<form name="frm">
<textarea name="body" rows="5" cols="40" onkeypress="checkchar(20)">
</textarea>
</form>
<script>
function checkchar(maxchar)
{
remaining =  parseInt(maxchar+1) - document.frm.body.value.length
if(remaining==0)
 alert('You character length is 20')
 document.frm.body.value = document.frm.body.value.substring(0,20)
 document.frm.body.focus()
}
</script>

Good luck
 

  Return to Index