博客
关于我
提交表单的检查代码
阅读量: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 -存储过程
查看>>
mysql /*! 50100 ... */ 条件编译
查看>>
mudbox卸载/完美解决安装失败/如何彻底卸载清除干净mudbox各种残留注册表和文件的方法...
查看>>
mysql 1264_关于mysql 出现 1264 Out of range value for column 错误的解决办法
查看>>
mysql 1593_Linux高可用(HA)之MySQL主从复制中出现1593错误码的低级错误
查看>>
mysql 5.6 修改端口_mysql5.6.24怎么修改端口号
查看>>
MySQL 8.0 恢复孤立文件每表ibd文件
查看>>
MySQL 8.0开始Group by不再排序
查看>>
mysql ansi nulls_SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON 什么意思
查看>>
multi swiper bug solution
查看>>
MySQL Binlog 日志监听与 Spring 集成实战
查看>>
MySQL binlog三种模式
查看>>
multi-angle cosine and sines
查看>>
Mysql Can't connect to MySQL server
查看>>
mysql case when 乱码_Mysql CASE WHEN 用法
查看>>
Multicast1
查看>>
mysql client library_MySQL数据库之zabbix3.x安装出现“configure: error: Not found mysqlclient library”的解决办法...
查看>>
MySQL Cluster 7.0.36 发布
查看>>
Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译
查看>>
MySQL Cluster与MGR集群实战
查看>>