我已经在表单上创建了一个php表单,其中有一个名为" alert“的字段,我想设置表单,以便如果"alert”复选框被勾选,用户必须输入备注,说明他们为什么要勾选警示框。
下面是我拥有的代码
if (empty($_POST['tutorComment']) && $_POST['alert'] == 'YES') {
echo "You must enter a comment on the student if you tick the alert box";
exit();
}如果我勾选了框并且没有输入注释,这似乎是有效的,但是当我勾选框并输入注释时,代码仍然在这里终止。
你知道我哪里错了吗?
发布于 2011-06-16 18:17:20
你的代码中有一个拼写错误,它是tutorComments而不是tutorComment。无论如何,如果您将您的代码替换为:
if( !strlen($_POST['tutorComment']) && isset($_POST['alert']) ){
echo "You must enter a comment on the student if you tick the alert box";
exit();
}发布于 2011-06-16 18:05:10
tutorComment是表单域的name吗?我会仔细检查拼写,大小写,并且你已经将它用作name,而不是id。
https://stackoverflow.com/questions/6370117
复制相似问题