• Resolved carioti

    (@carioti)


    Hi,
    I see in the validate field of a form that I can set it with lowercase letters. How can I set it with uppercase?
    Thanks,
    Daniele

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @carioti

    You can create a custom validation rule following this article.

    Here is an example of uppercase validation action:

    function um_custom_validate_uppercase_characters( $key, $array, $args ) {
    	if ( isset( $args[$key] ) && !preg_match('/[A-Z]/', $args[$key]) ) {
    		UM()->form()->add_error( $key, __( 'Please enter uppercase characters', 'ultimate-member' ) );
    	}
    }
    add_action( 'um_custom_field_validation_uppercase_characters', 'um_custom_validate_uppercase_characters', 30, 3 );
    Thread Starter carioti

    (@carioti)

    Thanks Aswin,
    I put the code in the theme’s functions.php.
    The function i recalled in the “custom action” field is “uppercase_characters” but
    It seems not working. Do I have to put the code in a different page?

    Plugin Support Aswin Giri

    (@aswingiri)

    Adding it to functions.php should work fine. Please try following codes if above one didn’t work for you:

    function um_custom_validate_uppercase_characters( $key, $array, $args ) {
    	if ( isset( $args[$key] ) && ! ctype_upper( $args[$key]) ) {
    		UM()->form()->add_error( $key, __( 'Please enter uppercase characters', 'ultimate-member' ) );
    	}
    }
    add_action( 'um_custom_field_validation_uppercase_characters', 'um_custom_validate_uppercase_characters', 30, 3 );
    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Hi @carioti,

    Please feel free to re-open this thread by changing the Topic Status to ‘Not Resolved’ if any other questions come up and we’d be happy to help. ??

    Regards,

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘set uppercase in validate field’ is closed to new replies.