<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
function checkForm(){
var input1 = document.getElementById("username");
var uValue = input1.value;
if(uValue.length >= 6){
return true;
}else{
alert("对不起,用户名太短啦!")
}
return false;
}
</script>
</head>
<body>
<form action="../01-网站首页的优化/网站首页.html" onsubmit="checkForm" >
用户名:<input type="text"/><br/>
<input type="submit" value="提交"/>
</form>
</body>
</html>
return false;这个放在alert("对不起,用户名太短啦!")下面,注意放在大括号里面
2.alert("对不起,用户名太短啦!")后面缺少;号
3.<input type="text"/>修改成<input type="text" id="username"/>