博客
关于我
提交表单的检查代码
阅读量: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 断电数据损坏,无法启动
查看>>
MySQL 日期时间类型的选择
查看>>
Mysql 时间操作(当天,昨天,7天,30天,半年,全年,季度)
查看>>
MySQL 是如何加锁的?
查看>>
MySQL 是怎样运行的 - InnoDB数据页结构
查看>>
mysql 更新子表_mysql 在update中实现子查询的方式
查看>>
MySQL 有什么优点?
查看>>
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询数据库所有表的字段信息
查看>>
【Java基础】什么是面向对象?
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>
MySQL 树形结构 根据指定节点 获取其下属的所有子节点(包含路径上的枝干节点和叶子节点)...
查看>>
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
查看>>