我做了个验证码的程序,但点按钮时就没问题,一按回车就清空文本框,请问怎样才可以点按钮和按回车一样的效果。
以下是代码:<?php
session_start();
if($_POST[button]) {
if($_POST[textfield]==$_SESSION[che]){
echo "<script>alert('验证码正确')</script>";
}else{
echo "<script>alert('验证码错误')</script>";
}
}
?>
<form id="form1" name="form1" method="post" action="" onSubmit="">
<img src='bitch.php'><br>
<label for="textfield"></label>
<input type="text" name="textfield" id="textfield" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
以下是代码:<?php
session_start();
if($_POST[button]) {
if($_POST[textfield]==$_SESSION[che]){
echo "<script>alert('验证码正确')</script>";
}else{
echo "<script>alert('验证码错误')</script>";
}
}
?>
<form id="form1" name="form1" method="post" action="" onSubmit="">
<img src='bitch.php'><br>
<label for="textfield"></label>
<input type="text" name="textfield" id="textfield" />
<input type="submit" name="button" id="button" value="提交" />
</form>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货