博客
关于我
提交表单的检查代码
阅读量:248 次
发布时间:2019-03-01

本文共 2381 字,大约阅读时间需要 7 分钟。

 
<script Language="JavaScript">
function FormCheck()
{
if (document.Form1.user.value =="")
{
alert("请填写您的用户名!");
document.Form1.user.focus();
return false;
}
var filter=/^\s*[.A-Za-z0-9_-]{5,15}\s*$/;
if (!filter.test(document.Form1.user.value)) {
alert("用户名填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 _ - .)长度不小于5个字符,不超过15个字符,注意不要使用空格。");
document.Form1.user.focus();
document.Form1.user.select();
return false;
}
if (document.Form1.pass.value =="")
{
alert("请填写您的密码!");
document.Form1.pass.focus();
return false;
}
if(document.Form1.confirmPassword.value==""){
alert("请输入您的确认密码!");
document.Form1.confirmPassword.focus();
return false;
}
var filter=/^\s*[.A-Za-z0-9_-]{5,15}\s*$/;
if (!filter.test(document.Form1.pass.value)) {
alert("密码填写不正确,请重新填写!可使用的字符为(A-Z a-z 0-9 _ - .)长度不小于5个字符,不超过15个字符,注意不要使用空格。");
document.Form1.pass.focus();
document.Form1.pass.select();
return false;
}
if (document.Form1.pass.value!=document.Form1.confirmPassword.value ){
alert("两次填写的密码不一致,请重新填写!");
document.Form1.pass.focus();
document.Form1.pass.select();
return false;
}
if (document.Form1.question.value =="")
{
alert("请输入密码提示问题!");
document.Form1.question.focus();
return (false);
}
if (document.Form1.answer.value =="")
{
alert("请输入密码提示答案!");
document.Form1.answer.focus();
return (false);
}
if (document.Form1.name.value =="")
{
alert("请输入您的姓名!");
document.Form1.name.focus();
return (false);
}
if (document.Form1.sf.value =="")
{
alert("请选择区域!");
document.Form1.sf.focus();
return (false);
}
if (document.Form1.city.value =="")
{
alert("请选择城镇名!");
document.Form1.city.focus();
return (false);
}
if (document.Form1.address.value =="")
{
alert("请输入您的联系地址!");
document.Form1.address.focus();
return (false);
}
if (document.Form1.post.value =="")
{
alert("请输入邮政编码!");
document.Form1.post.focus();
return (false);
}
if (document.Form1.phone.value =="")
{
alert("请输入您的联系电话!");
document.Form1.phone.focus();
return (false);
}
if (document.Form1.email.value =="")
{
alert("请输入您的电子邮件地址!");
document.Form1.email.focus();
document.Form1.email.select();
return false;
}
var filter=/^\s*([A-Za-z0-9_-]+(\.\w+)*@(\w+\.)+\w{2,3})\s*$/;
if (!filter.test(document.Form1.email.value)) {
alert("邮件地址不正确,请重新填写!");
document.Form1.email.focus();
document.Form1.email.select();
return false;
}
document.Form1.submit()
}
</script>
<FORM method="POST" action="Register_Confirm.asp" name="Form1" οnsubmit="return FormCheck();" >

转载地址:http://fndx.baihongyu.com/

你可能感兴趣的文章
MySQL DBA 数据库优化策略
查看>>
multi_index_container
查看>>
MySQL DBA 进阶知识详解
查看>>
Mura CMS processAsyncObject SQL注入漏洞复现(CVE-2024-32640)
查看>>
Mysql DBA 高级运维学习之路-DQL语句之select知识讲解
查看>>
mysql deadlock found when trying to get lock暴力解决
查看>>
MuseTalk如何生成高质量视频(使用技巧)
查看>>
mutiplemap 总结
查看>>
MySQL DELETE 表别名问题
查看>>
MySQL Error Handling in Stored Procedures---转载
查看>>
MVC 区域功能
查看>>
MySQL FEDERATED 提示
查看>>
mysql generic安装_MySQL 5.6 Generic Binary安装与配置_MySQL
查看>>
Mysql group by
查看>>
MySQL I 有福啦,窗口函数大大提高了取数的效率!
查看>>
mysql id自动增长 初始值 Mysql重置auto_increment初始值
查看>>
MySQL in 太多过慢的 3 种解决方案
查看>>
MySQL InnoDB 三大文件日志,看完秒懂
查看>>
Mysql InnoDB 数据更新导致锁表
查看>>
Mysql Innodb 锁机制
查看>>