patterns for text inputs

This commit is contained in:
fbsanchez 2022-01-26 12:52:36 +01:00
parent 11e0c99e74
commit e263d9a0c5
1 changed files with 19 additions and 9 deletions

View File

@ -2288,6 +2288,7 @@ function html_print_input_text_extended(
'autocomplete',
'form',
'list',
'pattern',
];
$output = '<input '.($password ? 'type="password" autocomplete="'.$autocomplete.'" ' : 'type="text" autocomplete="'.$autocomplete.'"');
@ -2572,13 +2573,16 @@ function html_print_input_password(
*
* The element will have an id like: "text-$name"
*
* @param string $name Input name.
* @param string $value Input value.
* @param string $alt Alternative HTML string (invalid - not used).
* @param integer $size Size of the input (optional).
* @param integer $maxlength Maximum length allowed (optional).
* @param boolean $return Whether to return an output string or echo now (optional, echo by default).
* @param boolean $disabled Disable the button (optional, button enabled by default).
* @param string $name Input name.
* @param string $value Input value.
* @param string $alt Alternative HTML string (invalid - not used).
* @param integer $size Size of the input (optional).
* @param integer $maxlength Maximum length allowed (optional).
* @param boolean $return Whether to return an output string or echo now (optional, echo by default).
* @param boolean $disabled Disable the button (optional, button enabled by default).
* @param string|null $list Some stuff.
* @param string|null $placeholder Some stuff.
* @param string|null $pattern Some stuff.
*
* @return string HTML code if return parameter is true.
*/
@ -2601,7 +2605,8 @@ function html_print_input_text(
$onKeyUp='',
$disabled=false,
$list='',
$placeholder=null
$placeholder=null,
$pattern=null
) {
if ($maxlength == 0) {
$maxlength = 255;
@ -2650,6 +2655,10 @@ function html_print_input_text(
$attr['placeholder'] = $placeholder;
}
if ($pattern !== null) {
$attr['pattern'] = $pattern;
}
return html_print_input_text_extended(
$name,
$value,
@ -4641,7 +4650,8 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['onKeyUp']) === true) ? $data['onKeyUp'] : ''),
((isset($data['disabled']) === true) ? $data['disabled'] : false),
((isset($data['list']) === true) ? $data['list'] : ''),
((isset($data['placeholder']) === true) ? $data['placeholder'] : '')
((isset($data['placeholder']) === true) ? $data['placeholder'] : ''),
((isset($data['pattern']) === true) ? $data['pattern'] : null)
);
break;