<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>
<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>
另外,请注意onsubmit的大小写
onSubmit=if(materials_id.value.length<10){alert('位数不对');return false;}
多谢