下面错在什么地方,不可行
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jquery-1.7.2.min.js" type="text/javascript"></script>
<style>
.mgs{ color:#F00; display:none;}
</style>
</head>
<body>
<form action="http://www.99m.com" onSubmit="return nameddd;">
<P class="p1"><input id="name" type="text" value="" onblur="indexname();" /><span class="mgs">用户名不能为空</span></P>
<input type="submit" value="Submit" />
</form>
<script>
var nameddd = false;
function indexname(){
var name = $('#name');
var namevalue = $('#name').val();
var g = /^.{3,8}$/;
if(namevalue == ''){
$('.mgs').show().html('用户名不能为空');
var nameddd = false;
}else if( !g.test(namevalue) ){
$('.mgs').show().html('用户名3位到8位');
var nameddd = false;
}else{
$('.mgs').hide();
var nameddd = true;
}
}
</script>
</body>
</html>
相关分类