试试..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<form name="test" method="post" action="Login.jsp">
用户名: <input type="text" name="username">
<br>
年龄: <input type="text" name="age">
<br>
性别: <input type="radio" name="sex" value="male" checked>男
<input type="radio" name="sex" value="female">女
<br>
密码: <input type="password" name="pwd">
<br>
确认密码: <input type="password" name="pwd1">
<br>
爱好: <input type="checkbox" name="intersting" value="football">football
<input type="checkbox" name="intersting" value="basketball">basketball
<input type="checkbox" name="intersting" value="ruuing">running
<br>
E-mail: <input type="text" name="email">
<br>
<input type="button" value="提交" onclick="javascript:checkForm();">
<input type="reset" value="取消">
</form>
</BODY>
</HTML> <script language="javascript">
var myReg = /^[A-Za-z0-9]\w+@(\w+\.)+[A-Za-z0-9]$/;
function checkForm()
{
var theForm=document.test;
if(theForm.username.value=="")
{
alert("please input username!");
theForm.username.focus();
}
else if(theForm.age.value=="")
{
alert("please input age");
theForm.age.focus();
}
else if((theForm.age.value <1)&&(theForm.age.value>100))
{
alert("age must between 1 and 100");
theForm.age.focus();
}
else if(theForm.pwd.value=="")
{
alert("please input password");
theForm.pwd.focus();
}
else if(theForm.pwd1.value=="")
{
alert("please input password again!");
theForm.pwd1.focus();
}
else if(theForm.pwd1.value != theForm.pwd.value)
{
alert("password not match");
theForm.pwd1.focus();
}
else if(theForm.email.value=="")
{
alert("please input E-mail");
theForm.email.focus();
}
else if(!(myReg.test(theForm.email.value)))
{
alert("E-mail not match!");
theForm.email.focus();
}
else
{
alert("提交成功");
theForm.submit();
}
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<form name="test" method="post" action="Login.jsp">
用户名: <input type="text" name="username">
<br>
年龄: <input type="text" name="age">
<br>
性别: <input type="radio" name="sex" value="male" checked>男
<input type="radio" name="sex" value="female">女
<br>
密码: <input type="password" name="pwd">
<br>
确认密码: <input type="password" name="pwd1">
<br>
爱好: <input type="checkbox" name="intersting" value="football">football
<input type="checkbox" name="intersting" value="basketball">basketball
<input type="checkbox" name="intersting" value="ruuing">running
<br>
E-mail: <input type="text" name="email">
<br>
<input type="button" value="提交" onclick="javascript:checkForm();">
<input type="reset" value="取消">
</form>
</BODY>
</HTML> <script language="javascript">
var myReg = /^[A-Za-z0-9]\w+@(\w+\.)+[A-Za-z0-9]$/;
function checkForm()
{
var theForm=document.test;
if(theForm.username.value=="")
{
alert("please input username!");
theForm.username.focus();
}
else if(theForm.age.value=="")
{
alert("please input age");
theForm.age.focus();
}
else if((theForm.age.value <1)&&(theForm.age.value>100))
{
alert("age must between 1 and 100");
theForm.age.focus();
}
else if(theForm.pwd.value=="")
{
alert("please input password");
theForm.pwd.focus();
}
else if(theForm.pwd1.value=="")
{
alert("please input password again!");
theForm.pwd1.focus();
}
else if(theForm.pwd1.value != theForm.pwd.value)
{
alert("password not match");
theForm.pwd1.focus();
}
else if(theForm.email.value=="")
{
alert("please input E-mail");
theForm.email.focus();
}
else if(!(myReg.test(theForm.email.value)))
{
alert("E-mail not match!");
theForm.email.focus();
}
else
{
alert("提交成功");
theForm.submit();
}
}
</script>
解决方案 »
- 【求助】一个图片切换功能的代码怎么实现有效果切换呢?
- jquery 如何获取title
- Javascript能在IE6.0运行,在IE8.0出问题,怎么回事?
- 窗体关闭大家怎么实现的?
- <script src="xxx" tppabs="http://www.xxx.com/xxx/xxx"></script>里面的tppabs=是什么意思??
- window.setTimeout()的用法
- 使用window.open()打开页面如何屏蔽热键(ie)
- Ext4.1在IE11上运行,发现onReady方法不运行!
- jquery easyui datagrid 不显示
- 如何在React脚手架里面引入样式框架
- 紧急求求助,还请各位没有睡觉的朋友,帮忙解决一个释放数组的小问题
- 图片预加载的问题
/^[A-Za-z0-9]\w+@(\w+\.)+[A-Za-z0-9]+$/
var myReg = new RegExp("/^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/");
改成
var myReg = /^[A-Za-z0-9]\w+@(\w+\.)+[A-Za-z0-9]+$/
你试试 我在本机上是调试成功的.....