1<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8"/>
</head>
<body>
</body>
<script type="text/javascript">
function fun(n){
if(n<1 || n>9){
alert("error");
}
else{
var i;
var result=1;
for(i=1;i<=n;++i)
{
result = result*i;
}
return result;
}
}
var a=fun(-4);
alert(a);
var b=fun(9);
alert(b);
</script>
<
html>
2 <!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8"/>
</head>
<body>
<table>
<tr>
<td>用户名:</td>
<td><input type="text" id="username" name="user" onblur="len()"/></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" id="username" name="password" onblur="len()"/></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="password" id="username" name="pass" onblur="len()"/></td>
</tr>
</table>
</body>
<script type="text/javascript">
function len(){
var userNameLength = document.getElementById('username').innerHTML;
if(userNameLength<6){
alert("长度不够!");
}
}
</script>
<
html>