日期:2014-05-17  浏览次数:20366 次

thinkphp中表单提交问题
thinkphp中,如下代码:我用一个button键没让他提交他怎么老自动提交,我得先验证成功在提交,验证失败直接跳走,可是他每次都提交,怎么搞啊,请thinkphp高手帮忙啊


<head>
<title>用户修改密码页面</title>
<script language="JavaScript" type="text/javascript" >
function check(){
if(myform.pw.value != myform.pw2.value)
{
alert("两次输入的新密码不相同");
document.location.href='__URL__/modpwindex';
}else{
document.getElementById("myfoid").submit();
}
}
</script>
</head>
<body>
<form action="__URL__/modpw" method="post" name="myform" id="myfoid">
<table>
  <tr><td>用户名:</td><td><input type="text" name="name"/></td></tr>
  <tr><td>旧密码:</td><td><input type="password" name="opw"/></td></tr>
  <tr><td>新密码:</td><td><input type="password" name="pw"/></td></tr>
  <tr><td>确认新密码:</td><td><input type="password" name="pw2"/></td></tr>
</table>
  <input type="button" name="aa" value="确定" onclick="check()"/>
</form>
</body>


------解决方案--------------------
function check(){
if(myform.pw.value=="" || myform.pw2.value==""){
alert(密码不能为空);
return false;
}
if(myform.pw.value != myform.pw2.value)
{
alert("两次输入的新密码不相同");
document.location.href='__URL__/modpwindex';
}else{
document.getElementById("myfoid").submit();
}
}
------解决方案--------------------
探讨

function check(){
if(myform.pw.value=="" || myform.pw2.value==""){
alert(密码不能为空);
return false;
}
if(myform.pw.value != myform.pw2.value)
{
alert("两次输入的新密码不相同");
document.location.href='__URL……

------解决方案--------------------
<input type="button" name="aa" value="确定" onclick="check();return false;"/>
------解决方案--------------------
myform.pw.value之类的写法在火狐里面是无效的