Hi folks.
I’ve been looking for hours for a simple way to limit the max/min character input length of a input form field. In html this is simply possible with <… maxlength=“x” minlength=“x”>. Have I missed something?
And keep up the good work, a great forum =)
No one can give a tip here? :-/
So far this cannot be done without js or php code.
Perhaps brick developers will notice this message and add for the Text field.
OR change code form widget /includes/elements/form.php
find ‘required’ => [ ‘type’, ‘=’, [ ‘number’ ] ],
and change ‘required’ => [ ‘type’, ‘=’, [ ‘number’ , ‘text’] ],
find // Number min/max
and add before
// Text min/max
if ( $field['type'] === 'text' ) {
if ( isset( $field['min'] ) ) {
$this->set_attribute( "field-$index", 'minlength', $field['min'] );
}
if ( isset( $field['max'] ) ) {
$this->set_attribute( "field-$index", 'maxlength', $field['max'] );
}
}
1 Like
@clickfusion63, thank you!
I have tested it, it works great! Unfortunately the form.php could be overwritten with the next update. I have sent the problem to the Ideaboard as a suggestion for improvement.