提交表单之前对表单进行检查的方法 onsubmit="return checkSubmit();"
2013-12-01 13:33
483 查看
<!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();"
- ajax提交,form表单提交,onsubmit="return checksubmit()"提交验证
- onsubmit="return false"用在表单,提交时直接按回车作用
- 总结:form中使用onSubmit="return false"防止表单自动提交,以及s...
- FORM中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- 总结:form中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- FORM中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- FORM中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- FORM中使用onSubmit="return false"防止表单自动提交
- 总结:FORM中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- 表单提交 onsubmit="return false"
- FORM中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- 总结:FORM中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- FORM中使用onSubmit="return false"防止表单自动提交
- 总结:FORM中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- 总结:form中使用onSubmit="return false"防止表单自动提交,以及submit和button提交表单的区别
- myeclipse10中表单中的JS函数无法写return,onsubmit="return check();"处出错
- form name="form" method="post" onSubmit="return CheckForm(this)
- jsp页面onsubmit="return checklogin();"该解决方案给
- 在jsp中form的onsubmit事件,onsubmit="return 方法名()",编译环境报错的解决办法