Added the 'required' attribute to the input text and input text password through a function parameter

(cherry picked from commit 4f2c35ac63dc2d922607f7cb915b065a9cf77446)
This commit is contained in:
Alejandro Gallardo Escobar 2015-07-13 12:40:28 +02:00
parent 73e0e91647
commit c5b84f1d2b

View File

@ -772,7 +772,7 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
"title", "xml:lang", "onfocus", "onblur", "onselect", "title", "xml:lang", "onfocus", "onblur", "onselect",
"onchange", "onclick", "ondblclick", "onmousedown", "onchange", "onclick", "ondblclick", "onmousedown",
"onmouseup", "onmouseover", "onmousemove", "onmouseout", "onmouseup", "onmouseover", "onmousemove", "onmouseout",
"onkeypress", "onkeydown", "onkeyup"); "onkeypress", "onkeydown", "onkeyup", "required");
$output = '<input '.($password ? 'type="password" autocomplete="off" ' : 'type="text" '); $output = '<input '.($password ? 'type="password" autocomplete="off" ' : 'type="text" ');
@ -816,7 +816,7 @@ function html_print_input_text_extended ($name, $value, $id, $alt, $size, $maxle
*/ */
/* Exact operator because we want to show "0" on the value */ /* Exact operator because we want to show "0" on the value */
if ($$attribute !== '') { if ($attribute !== '') {
$output .= $attribute.'="'.$$attribute.'" '; $output .= $attribute.'="'.$$attribute.'" ';
} }
elseif ($default != '') { elseif ($default != '') {
@ -910,11 +910,16 @@ function html_print_div ($options, $return = false) {
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function html_print_input_password ($name, $value, $alt = '', $size = 50, $maxlength = 255, $return = false, $disabled = false) { function html_print_input_password ($name, $value, $alt = '', $size = 50, $maxlength = 255, $return = false, $disabled = false) {
$output = html_print_input_text_extended ($name, $value, 'password-'.$name, $alt, $size, $maxlength, $disabled, '', '', true, true); if ($maxlength == 0)
$maxlength = 255;
if ($return) if ($size == 0)
return $output; $size = 10;
echo $output;
if ($required)
$attr = array('required' => 'required');
return html_print_input_text_extended ($name, $value, 'password-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return, true);
} }
/** /**
@ -932,14 +937,17 @@ function html_print_input_password ($name, $value, $alt = '', $size = 50, $maxle
* *
* @return string HTML code if return parameter is true. * @return string HTML code if return parameter is true.
*/ */
function html_print_input_text ($name, $value, $alt = '', $size = 50, $maxlength = 255, $return = false, $disabled = false) { function html_print_input_text ($name, $value, $alt = '', $size = 50, $maxlength = 255, $return = false, $disabled = false, $required = false) {
if ($maxlength == 0) if ($maxlength == 0)
$maxlength = 255; $maxlength = 255;
if ($size == 0) if ($size == 0)
$size = 10; $size = 10;
return html_print_input_text_extended ($name, $value, 'text-'.$name, $alt, $size, $maxlength, $disabled, '', '', $return); if ($required)
$attr = array('required' => 'required');
return html_print_input_text_extended ($name, $value, 'text-'.$name, $alt, $size, $maxlength, $disabled, '', $attr, $return);
} }
/** /**