[Javascript] How can i strict the length of TextAread form element ?
Manuel Socarras Reyes
msocarras at terra.es
Mon Dec 24 09:09:19 CST 2001
something like this should work, specially if you don't want the user typing
more chars than allowed
--
Saludos,
Manuel Socarrás Reyes <msocarras at terra.es>
Barcelona. Spain
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
function restrictLenght(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
</script>
</head>
<body bgcolor="#FFFFFF">
<form name="comments">
<p>Type your comments:</p>
<p>
<textarea cols=40 name="typed" rows=3 " wrap="virtual"
onKeyDown="restrictLenght(comments.typed,comments.left,120);" >
</textarea>
</p>
<p>
<input type="text" name="left" value="120">
</p>
</form>
</body>
</html>
"M. Amin" wrote:
> Dear All,
> I tried to strict the length of TextAread form element using the
> maxlength attribute but
> it did n't work. So, How can i strict the length of TextAread form element ?
>
> Any help will be appreciated,
>
> Regards,
> M. Amin
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list