From 6a6d1cfeb4dc873de03929501c1c124642dc9d14 Mon Sep 17 00:00:00 2001 From: mirabellette <34450971+mirabellette@users.noreply.github.com> Date: Mon, 3 Dec 2018 15:21:06 +0100 Subject: [PATCH] Possibility to make the captcha's input required I added to the captcha's input text a required tag in order to oblige the user to fill it. It could be disable with 'input_required' => false. For example: Securimage::getCaptchaHtml(array('input_required' => false)) --- securimage.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/securimage.php b/securimage.php index b4f4d2c..6b995ac 100644 --- a/securimage.php +++ b/securimage.php @@ -1368,6 +1368,7 @@ public static function getCaptchaHtml($options = array(), $parts = Securimage::H $input_text = (isset($options['input_text'])) ? $options['input_text'] : 'Type the text:'; $input_id = (isset($options['input_id'])) ? $options['input_id'] : 'captcha_code'; $input_name = (isset($options['input_name'])) ? $options['input_name'] : $input_id; + $input_required = (isset($options['input_required'])) ? (bool)$options['input_required'] : true; $input_attrs = (isset($options['input_attributes'])) ? $options['input_attributes'] : array(); $image_attrs = (isset($options['image_attributes'])) ? $options['image_attributes'] : array(); $error_html = (isset($options['error_html'])) ? $options['error_html'] : null; @@ -1533,6 +1534,7 @@ public static function getCaptchaHtml($options = array(), $parts = Securimage::H $input_attrs['name'] = $input_name; $input_attrs['id'] = $input_id; $input_attrs['autocomplete'] = 'off'; + if ($input_required) $input_attrs['required'] = $input_required; foreach($input_attrs as $name => $val) { $input_attr .= sprintf('%s="%s" ', $name, htmlspecialchars($val));