Here is a full working example. Since Javascript is clientside and php is serverside the two have no direct effect on one another
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Textarea Length Limiter</title>
<script type="text/javascript">
<!--
function limitChars(field,maxLength,dispName) {
if(field.value.length > maxLength) {
alert(dispName + ' can only contain ' + maxLength + ' characters.');
field.value = field.value.substr(0,maxLength);
} //end if
return true;
} //end limitChars
function charsLeft(outField,inField,maxLength) {
outField.value = maxLength - inField.value.length;
return true;
} //end charsLeft
//-->
</script>
</head>
<body style="width: 390px;">
<h1>Textarea Character Limiter</h1>
<p style="text-align: justify;">
<b>Warning:</b> Do not depend on this method to limit the characters as someone
could turn scripting off on their browser to get around this. You must back this
up with a length check on the server side as well or your script will have
unpredictable results.</p>
<form action="void">
<div>
Description:<br />
<textarea name="description" cols="45" rows="5"
onkeyup="limitChars(document.forms[0].description,1000,'Description');
charsLeft(document.forms[0].remaining,document.forms[0].description,1000);"></textarea><br />
Characters Left: <input type="text" name="remaining" value="1000" size="4"
style="border-style: hidden;border-width: 0px;"/><br /><br />
</div>
</form>
</body>
</html>