【发布时间】:2010-11-23 10:02:39
【问题描述】:
我开发的 wordpress 小部件有问题。
它只是一个包含一个电子邮件字段、一个按钮和一个复选框的表单。
当用户点击提交时,我想验证是否勾选了复选框,如果是则提交表单...
我的问题是即使未勾选复选框也提交了表单。页面已重新加载。
这是我的代码的简短版本:
<?php if(isset($_POST['rules']) && $_POST['rules'] == 'Yes')
{
echo 'The checkbox was selected';
} else {
echo 'The checkbox wasn\'t selected';
} ?>
<form id="form-invite" method="post" action="">
<label>Your friend(s) email :</label>
<br/>
<small style="text-transform:uppercase;font-family:Arial;font-size:9px;color:#333;"<em>Multiple emails separated by comma.</em></small>
<input class="kolom" type="text" name="email" id="email"/>
<input class="button-primary classic-button" type="submit" name="send-them" value="Send Invitation"/>
<input type="checkbox" name="rules" value="Yes" /> <span id="rulesInfo">I read the Privacy Policy</span><br/>
<span id="emailInfo"></span>
</form>
【问题讨论】:
标签: php wordpress validation