From 216cb4f9d468dcb68763113edd84404992e47dd7 Mon Sep 17 00:00:00 2001 From: Champ Camba Date: Sat, 13 May 2017 19:52:03 +0800 Subject: [PATCH] Fix Min and Max numeric values validation --- core/um-actions-form.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/um-actions-form.php b/core/um-actions-form.php index 1b46d942..f95e64c5 100644 --- a/core/um-actions-form.php +++ b/core/um-actions-form.php @@ -272,6 +272,18 @@ } } + if ( isset( $array['min'] ) && is_numeric( $args[ $key ] ) ) { + if ( isset( $args[ $key ] ) && $args[ $key ] < $array['min'] ) { + $ultimatemember->form->add_error( $key, sprintf(__('Minimum number limit is %s','ultimatemember'), $array['min'] ) ); + } + } + + if ( isset( $array['max'] ) && is_numeric( $args[ $key ] ) ) { + if ( isset( $args[ $key ] ) && $args[ $key ] > $array['max'] ) { + $ultimatemember->form->add_error( $key, sprintf(__('Maximum number limit is %s','ultimatemember'), $array['max'] ) ); + } + } + if ( isset( $array['validate'] ) && !empty( $array['validate'] ) ) { switch( $array['validate'] ) { @@ -282,9 +294,11 @@ break; case 'numeric': + if ( $args[$key] && !is_numeric( $args[$key] ) ) { $ultimatemember->form->add_error($key, __('Please enter numbers only in this field','ultimatemember') ); } + break; case 'phone_number': @@ -489,4 +503,5 @@ } // end if ( isset in args array ) } + }