<html>
<head>
<script language="javascript">
function verifyForm(){
var ass=document.getElementsByName("assetName");
if(ass[0].value.length==0){
alert("名称输入为空!");
return false;
}
if(ass[0].value.length>15){
alert("名称输入长度不能超过15个字符!");
return false;
}
}
</script>
</head>
<body>
<form name="xx">
<input name="assetName" type="text"/>
<--根据return 返回值的TRUE或FALSE 判定是否提交表单--->
<input type="submit" οnclick="return verifyForm()"/>
</form>
</body>
</html>
<head>
<script language="javascript">
function verifyForm(){
var ass=document.getElementsByName("assetName");
if(ass[0].value.length==0){
alert("名称输入为空!");
return false;
}
if(ass[0].value.length>15){
alert("名称输入长度不能超过15个字符!");
return false;
}
}
</script>
</head>
<body>
<form name="xx">
<input name="assetName" type="text"/>
<--根据return 返回值的TRUE或FALSE 判定是否提交表单--->
<input type="submit" οnclick="return verifyForm()"/>
</form>
</body>
</html>