*sigh* empty('0') evaluates to true even though the string is not empty.
[misc/kostenrechnung] / ajax / ajax.php
index f8a62c1..2919669 100644 (file)
@@ -90,7 +90,7 @@ function save($mask)
                  "sys_edit = now()");
 
   foreach ($mask['edit'] as $field => $info) {
-    if ($info['required'] === true && empty($_POST[$field]))
+    if ($info['required'] === true && !strlen($_POST[$field]))
       return array('error' => sprintf('Pflichtfeld %s nicht ausgefüllt', $info['name']),
                   'errormsg' => 'Pflichtfelder nicht ausgefüllt');
 
@@ -141,7 +141,7 @@ function insert($mask)
   $values = array("'".pg_escape_string($_SESSION['sys']['login'])."'", 'now()');
 
   foreach ($mask['edit'] as $field => $info) {
-    if ($info['required'] === true && empty($_POST[$field]))
+    if ($info['required'] === true && !strlen($_POST[$field]))
       return array('error' => sprintf('Pflichtfeld %s nicht ausgefüllt', $info['name']),
                   'errormsg' => 'Pflichtfelder nicht ausgefüllt');