Merge pull request #1459 from ultimatemember/fix/alpha_numeric_validation

alpha_numeric validation to fields
This commit is contained in:
Mykyta Synelnikov
2024-02-06 15:23:42 +02:00
committed by GitHub
+8
View File
@@ -987,6 +987,14 @@ function um_submit_form_errors_hook_( $submitted_data, $form_data ) {
}
break;
case 'alpha_numeric':
if ( '' !== $submitted_data[ $key ] ) {
if ( ! preg_match( '/^[\p{L}0-9\s]+$/u', str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {
UM()->form()->add_error( $key, __( 'You must provide alphabetic letters or numbers', 'ultimate-member' ) );
}
}
break;
case 'lowercase':
if ( '' !== $submitted_data[ $key ] ) {
if ( ! ctype_lower( str_replace( ' ', '', $submitted_data[ $key ] ) ) ) {