<html>
<head><script language="javascript">
<!--function mychk()
  {
   if(document.myform.mytxt.value.length>40)
      {
      alert("长度太长了,请换一个试试!");
      document.myform.mytxt.select();
      return false;   
      }
  return true;  }-->
</script></head>
<body>
<form name="myform" method="post" action="my.php" onsubmit="return mychk()">
 .......
</form>
</body>
</html>