html,js表单的验证,下面代码是想实现当输入6个字符以上用户名通过,少于时报错,但执行不了,求改错
(要求:用户名和text框和报错语句必须在一行)<!doctypehtml><htmllang="en"><head><metacharset="UTF-8"><meta...
(要求:用户名和text框和报错语句必须在一行)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script>
function check(){
var e,len;
e=doucument.getElementById("un");
len=e.length;
if(len<=6){
span.innerHTML="用户名必须是6个字符以上";
e.focus();
}
else
span.innerHTML="";
}
</script>
</head>
<body>
<form action="">
<p>
用户名:
<input name="username" type="text" value="" size="20" maxlength="20" id="un" onblur="check()"/>
<span></span>
</p>
</form>
</body>
</html> 展开
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script>
function check(){
var e,len;
e=doucument.getElementById("un");
len=e.length;
if(len<=6){
span.innerHTML="用户名必须是6个字符以上";
e.focus();
}
else
span.innerHTML="";
}
</script>
</head>
<body>
<form action="">
<p>
用户名:
<input name="username" type="text" value="" size="20" maxlength="20" id="un" onblur="check()"/>
<span></span>
</p>
</form>
</body>
</html> 展开
展开全部
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script>
function check(){
var span=document.getElementById("span");
var e=document.getElementById("un");
var value=e.value;
var len=value.length;
if(!len||len<=6){
span.innerHTML="用户名必须是6个字符以上";
e.focus();
}
else{
span.innerHTML="";
}
}
</script>
</head>
<body>
<form action="">
<p>
用户名:
<input name="username" type="text" value="" size="20" maxlength="20" id="un" onblur="check()"/>
<span id="span"></span>
</p>
</form>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Document</title>
<script>
function check(){
var span=document.getElementById("span");
var e=document.getElementById("un");
var value=e.value;
var len=value.length;
if(!len||len<=6){
span.innerHTML="用户名必须是6个字符以上";
e.focus();
}
else{
span.innerHTML="";
}
}
</script>
</head>
<body>
<form action="">
<p>
用户名:
<input name="username" type="text" value="" size="20" maxlength="20" id="un" onblur="check()"/>
<span id="span"></span>
</p>
</form>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询