我需要检查几个标签是否“不为空”。为此,我使用:
<input id="designation" type="text" size="12" disabled="disabled" />
然后,我需要在表格中放置几个<input ...>
。所有这些都是用HTML创建的。我需要检查是否有任何标签是空的。
$erreurs = array();
// Check if the tag is not empty
if((empty($_POST['CodetERDF']))) {
$erreurs[] = 'Veuillez renseigner le codet ERDF.';
echo 'Veuillez renseigner le codet ERDF.';
}`
但我的代码似乎不起作用,我不明白为什么。
答案 0 :(得分:2)
已禁用的输入未发布到服务器,因此它们永远不会显示在$_POST
中。
同样适用于没有name
属性的输入,因为name
属性定义了$_POST
中的关键字。
替代方案是将它们readonly
,hidden
或只是在会话变量中设置值/将其保留在服务器上。