作者rex921 (小雷)
看板PHP
标题[请益] 表单验证...
时间Fri Aug 20 17:34:55 2010
小的又来求救了@@
<form name="msg_form" action="show/msg.php" method="post"
onsubmit="msg_check()">
~~~
一些栏位
~~~~~
<input name="msg_send" type="submit" value="寄 出" />
</form>
msg_check() --->是另一个php党 是判断msg_form的栏位是否为空然後return回来
以下是msg_check的程式码....
<script type="text/javascript">
function msg_check(){
if(document.msg_form.msg_name.value==""){
alert("尚未输入姓名");
return false;
}
else{
return true;
}
}
</script>
但是我按下"寄出"之後 是跳出了"尚未输入姓名" return回来之後 他就将表单送出去了
照理说应该是return false 而表单不会送出吧~"~
怎麽会这样 请教前辈!!
--
活在我不懂的道理
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.64.102.55
1F:推 cleanwind:丢水球不理我 = =+ 08/20 18:13
2F:→ cleanwind:把 input type 改成 botton , JS 加入 submit(); 08/20 18:14
3F:→ cleanwind:啧 ... 我看错了 ~"~ 08/20 18:22
4F:→ cleanwind:onsubmit 改成 onsubmit="return msg_check();" 08/20 18:27