验证问题?求例子 就像这样的验证 ,谢谢了 给个列子 就行 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if($(#"emailid").val()="")alert('请输入你的Email地址')if($(#"nameid").val()="")alert('请输入用户名') 粗略的写了个简单的例子 将就着看吧<!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=gb2312" /><title>简单例子</title><style type="text/css">*{padding:0; margin:0; font-size:12px;}#tips{color:red;}#input1{border:1px solid #ccc;}#submit1{width:40px; height:18px; line-height:18px; border:1px solid #ccc;}</style><script>function checkFrm(){ var aa=document.form1.email.value if (aa==""){ document.getElementById('tips').innerHTML="请填写邮箱"; return false; }}</script></head><body><form name="form1" method="post" action="" onsubmit="return checkFrm()">邮箱:<input type="text" id="input1" name="email"><span id="tips"></span><br /><input type="submit" id="submit1" value="提交"></form></body> 这个可以用ajax 向后台请求,然后后台判断输入是否正确,然后返回到前台。再document.getElementById('tips').innerHTML=""; document.getElementById('msg').innerHTML="<img src='tips.gif'/><font color='red'>请填写邮箱</font>";当合法的时候,即验证通过的时候document.getElementById('msg').innerHTML = "";即可<div id="msg"></div> <!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=gb2312" /><title>例子</title><script>function checkForm(){ var e=document.form1.email.value; if (e==""){ alert("请输入email"); return } var name=document.form1.name.value; if(name==""){ alert(请输入用户名); return; }}</script></head><body><form name="form1" method="post" action="">Email:<input type="text" id="email" name="email"><br/>用户名:<input type="text" id="name" name="name"><input type="button" id="tj" value="提交" onclick="checkForm();"></form></body> 我是菜鸟,想来问个弱弱的关于IE加载项的问题! select名称使用参数定义的问题请假,急急急!!! jquery版本问题 《javascript网页制作彻底研究》PDG格式电子书籍 apache服务器,静态网页。能不能做网站计数器? 高手帮个忙吧~~~~ dom小问题,setAttribute(..,..)第二个参数如何调用函数? 请问高手变量的问题! 在线等结果:jquerypost表单返回XMLHttpRequest.status=0 MyEclipse中Ctrl+Shift+F快捷键格式化 js代码时不换行 急!求两个正则表达式 ^[a-zA-Z0-9]*$" 求解
<!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=gb2312" />
<title>简单例子</title>
<style type="text/css">
*{padding:0; margin:0; font-size:12px;}
#tips{color:red;}
#input1{border:1px solid #ccc;}
#submit1{width:40px; height:18px; line-height:18px; border:1px solid #ccc;}
</style>
<script>
function checkFrm(){
var aa=document.form1.email.value
if (aa==""){
document.getElementById('tips').innerHTML="请填写邮箱";
return false;
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="" onsubmit="return checkFrm()">
邮箱:<input type="text" id="input1" name="email"><span id="tips"></span><br />
<input type="submit" id="submit1" value="提交">
</form>
</body>
再
document.getElementById('tips').innerHTML="";
当合法的时候,即验证通过的时候document.getElementById('msg').innerHTML = "";即可
<div id="msg"></div>
<!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=gb2312" />
<title>例子</title>
<script>
function checkForm(){
var e=document.form1.email.value;
if (e==""){
alert("请输入email");
return
}
var name=document.form1.name.value;
if(name==""){
alert(请输入用户名);
return;
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
Email:<input type="text" id="email" name="email"><br/>
用户名:<input type="text" id="name" name="name">
<input type="button" id="tj" value="提交" onclick="checkForm();">
</form>
</body>