提交表单之前对表单进行检查的方法 onsubmit="return checkSubmit();"
<!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=<?php echo $cfg_soft_lang; ?>" />
<title>更改帐号基本资料 - 会员中心 - <?php echo $cfg_webname; ?></title>
<script type="text/javascript">
function checkSubmit()
{
if(document.form2.oldpwd.value=='')
{
document.form2.oldpwd.focus();
alert("旧密码必须填写!");
return false;
}
if(document.form2.userpwdok.value!=document.form2.userpwd.value)
{
document.form2.userpwdok.focus();
alert("两次密码不一致!");
return false;
}
if(document.form2.email.value=="")
{
document.form2.email.focus();
alert("Email不能为空!");
return false;
}
if(document.form2.uname.value=="")
{
document.form2.uname.focus();
alert("用户昵称不能为空!");
return false;
}
if(document.form2.vdcode.value=="")
{
document.form2.vdcode.focus();
alert("验证码不能为空!");
return false;
}
}
</script>
</head>
<body>
<!--提交表单前先执行checkSubmit(),检查表单各项是否合规-->
<form action="edit_baseinfo.php" method="post" enctype="multipart/form-data" name="form2" onsubmit="return checkSubmit();">
<input type="hidden" name="dopost" value="save" />
<div class="postForm">
<p class="cellBg">
<label style="width:90px">昵称:</label>
<input name="uname" type="text" id="uname" value="<?php echo $row['uname']; ?>" class="intxt" style="width:100px"/>
</p>
<p>
<label>原登陆密码:</label>
<input name="oldpwd" type="password" id="oldpwd" class="intxt" /> <span style="color:red;">*</span>
</p>
<p class="cellBg">
<label>新密码:</label>
<input name="userpwd" type="password" id="userpwd" class="intxt" />
<span id="_userpwdok">(不修改密码请保留此项为空)</span>
</p>checkSubmit()
<p>
<label>确认新密码:</label>
<input name="userpwdok" type="password" id="userpwdok" value="" class="intxt" />
<span id="_userpwdok2">(不修改密码请保留此项为空)</span> </span>
</p>
<p class="cellBg">
<label><span class="tdl">电子邮箱</span>:</label>
<input name="email" type="text" id="email" value="<?php echo $row['email']; ?>" class="intxt"/><br>
<span id="_email" style="margin-left:80px"> <span style="color:red;">*</span> (每个电子邮邮箱只能注册一个帐号,要修改电子邮箱必须填写正确安全问题的答案)</span>
</p>
<p class="cellBg">
<label>验证码:</label>
<input name="vdcode" type="text" id="vdcode" style='width:50px;text-transform:uppercase;' class="intxt" />
<img src="../include/vdimgck.php" align="absmiddle" alt="看不清?点击更换" style="cursor:pointer" onclick="this.src=this.src+'?'" />
</p>
<p>
<button class="button2" type="submit">更新</button>
<button class="button2 ml10" type="reset">重设</button>
</p>
</div>
</form>
</body>
</html>
如果是onsubmit="return false;"则是表示阻止表单提交,例:<form name="form1" method="post" onsubmit="return
false;"></from>
提交表单之前对表单进行检查的方法 onsubmit="return checkSubmit();"的更多相关文章
- 谈谈Enter回车键提交表单那些事 回车搜索 enter搜索
我们在做系统前端的时候,往往会用到form标签,采用jquery插件做表单验证.我们信誓旦旦的一位把一切都做好的时候,并且检查一遍又一遍的时候,意向不到的事情发生了,也许是出于一种意外,而这种意外我们 ...
- JQuery ajax提交表单及表单验证
JQuery ajax提交表单及表单验证 博客分类: jsp/html/javascript/ajax/development Kit 开源项目 注:经过验证,formValidator只适合一个 ...
- js防止回车(enter)键提交表单及javascript中event.keycode
如何防止回车(enter)键提交表单,其实很简单,就一句话.onkeydown="if(event.keyCode==13)return false;"把这句写在from标签里 ...
- 前端表单中有按钮button自动提交表单
问题描述 在设计表单时,表单内有一个按钮<button>,该按钮是用来获取其他数据或执行其他操作的.并不是让他提交表单. 解决方案 1) 设置 form 的 onsubmit='retur ...
- JS:JS判断提交表单不能为空等验证
这段代码在<form>中有οnsubmit="return on_submit()",如果 onsubmit ()返回 fasle,表单的元素就不会提交,即action ...
- HTML5对表单的约束验证
在HTML5中增加了许多新的功能,用于表单提交到服务器之前对表单进行数据的验证(抢了javascript的饭碗),有了这些功能,即便是javascript没有加载进来还是可以确保基本的验证.换句话说, ...
- onsubmit对表单的拦截
今天遇到一个问题:在对同name 的input 表单时 判断其值是否有效 用了each判断 当初错误的做法: function check_goods() { var regs = /^\d+$/; ...
- ASP.NET MVC 网站开发总结(五)——Ajax异步提交表单之检查验证码
首先提出一个问题:在做网站开发的时候,用到了验证码来防止恶意提交表单,那么要如何实现当验证码错误时,只是刷新一下验证码,而其它填写的信息不改变? 先说一下为什么有这个需求:以提交注册信息页面为例,一般 ...
- jquery 通过submit()方法 提交表单示例
jquery 通过submit()方法 提交表单示例: 本示例:以用户注册作为例子.使用jquery中的submit()方法实现表单提交. 注:本示例仅提供了对表单的验证,本例只用选用了三个字段作为测 ...
随机推荐
- python语言积累
调试打印堆栈 import traceback traceback.print_exc() #打印堆栈的详细信息
- 用MODI OCR 21种语言
作者:马健邮箱:stronghorse_mj@hotmail.com发布:2007.12.08更新:2012.07.09按照<MODI中的OCR模块>一文相关内容进行修订2012.07.0 ...
- socket网络服务实战
一.epoll模型的构建 由于网络服务高并发的需求,一般socket网络模型都采用epoll模型,有关epoll模型的原理在相关论坛中有许多讲述,在此不做重复讲解,主要讲一讲epoll模型的封装实现. ...
- 与HDFS交互-By shell命令
Shell命令的开头有三种: hadoop fs hadoop dfs hdfs dfs 关于具体命令之前写过 可查看:https://www.cnblogs.com/floakss/p/970344 ...
- 无侵入进行SDK的初始化
话不多说,下面开始,nagios具体的介绍,可以搜一下,这篇文章为作者在实际操作中整理出来,写出来的都是负责人的内容~ 环境准备 此文档共用2台服务器的配置,操作系统均为centOS6.7,安装用户都 ...
- Quadratic Residues POJ - 1808 二次剩余定理
\(\color{#0066ff}{题目链接 }\) link \(\color{#0066ff}{ 题解 }\) 结论题 \((\frac{a}{p})=a^{\frac{p-1}{2}}\mod ...
- [USACO08MAR]跨河River Crossing dp
题目描述 Farmer John is herding his N cows (1 <= N <= 2,500) across the expanses of his farm when ...
- java.sql.Date/ java.util.Date/ java.util.Calendar 用法与区别
在 JDK API 这样解释," 在 JDK 1.1 之前,类 Date 有两个其他的函数.它允许把日期解释为年.月.日.小时.分钟和秒值.它也允许格式化和解析日期字符串.不过,这些函数的 ...
- zabbix监控java内存的脚本
#!/bin/bash # 截取java的pid号 java_pid=`netstat -lnpt |grep |awk -F '/' '{print $1'}` # 截取$jstat命令的位置 js ...
- JavaScript Succinctly 读后笔记
1.JavaScript does not have block scope 2.Scope is determined during function definintion, not invo ...