- add alpha_numeric validation to fields

This commit is contained in:
ashubawork
2024-02-06 15:19:33 +02:00
parent dc176b67bc
commit d26de2a85c
+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 ] ) ) ) {