Skip to content

Commit c5aa23d

Browse files
authored
gw-min-and-max-character-limit.php: Added support to run validation only when the field has a value.
1 parent 3b07d86 commit c5aa23d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

gravity-forms/gw-min-and-max-character-limit.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ public function validate_character_count( $result, $value, $form, $field ) {
8585
}
8686
}
8787

88+
// If value is empty, don't do validation.
89+
if ( empty( $value ) ) {
90+
return $result;
91+
}
92+
8893
$char_count = mb_strlen( $value );
8994
$is_min_reached = $this->_args['min_chars'] !== false && $char_count >= $this->_args['min_chars'];
9095
$is_max_exceeded = $this->_args['max_chars'] !== false && $char_count > $this->_args['max_chars'];

0 commit comments

Comments
 (0)