function validateInput(&$errors) { global $input; if (!isRequired($input) || !isNumeric($input)) { $errors['input'][] = 'You must enter a number.'; } return empty($errors); }
function validateForm(&$errors) { global $input; if (!isRequired($input) || !inputLength($input)) { $errors[] = 'You must add 10 numbers separated by comma (with no space inbetween).'; } else { if (!validInput($input)) { $errors[] = 'Numbers only.'; } } }
function createDatalistInput($value, $form_id, $name, $label, $other, $data, $data_key, $input_hints) { if (empty($data)) { return '<label class="label_error">Cannot display this information</label>'; } $_value = ""; if ($value !== NULL) { $_value = 'value="' . $value . '"'; } $return = '<label for="' . $name . '_' . $form_id . '">' . $label . isRequired($other) . addHintIcon() . '</label>'; $return .= inputHint($input_hints); $return .= '<input class="input_datalist" id="' . $name . '_' . $form_id . '" list="' . $name . '_' . $form_id . '_datalist" name="' . $name . '" ' . $_value . '>'; $return .= '<datalist id="' . $name . '_' . $form_id . '_datalist">'; if ($data_key === NULL) { foreach ($data as $option) { $return .= '<option value="' . $option . '">'; } } else { foreach ($data as $option) { $return .= '<option value="' . $option[$data_key] . '">'; } } $return .= '</datalist>'; $return .= '<div class="input_tooltip" id="' . $name . '_' . $form_id . '_tooltip"></div>'; return $return; }