• VoN

    (@webdesignervon)


    In both the phone number section and a custom Bank Details field, I made use of the number field type and it works perfectly.

    My problem is how to go about restricting input to 10 characters. Not less than 10 and not more than 10.

    Any help would be appreciated.

    Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter VoN

    (@webdesignervon)

    Any help with this would be appreciated.

    Plugin Author WC Lovers

    (@wclovers)

    Use this snippet for the purpose-

    add_filter( 'wcfm_membership_registration_fields_phone', function( $fields ) {
    	if( isset( $fields['user_phone'] ) ) {
    		$fields['user_phone']['type'] = 'number';
    		$fields['user_phone']['attributes'] = array( 'maxlength' => 10 );
    	}
    	if( isset( $fields['phone'] ) ) {
    		$fields['phone']['type'] = 'number';
    		$fields['phone']['attributes'] = array( 'maxlength' => 10 );
    	}
    	return $fields;
    }, 50, 1 );
    Thread Starter VoN

    (@webdesignervon)

    Thank you. I found this on your WClover forum and tried it but for some odd reason, this code doesn’t work.

    Plugin Author WC Lovers

    (@wclovers)

    Where are you adding this code?

    Between, this code works for registration form phone field.

    Thread Starter VoN

    (@webdesignervon)

    I’m adding it using the Code Snippet plugin.

    Thread Starter VoN

    (@webdesignervon)

    Is that the problem? I asked because I’ve used other codes that work just fine using the Code Snippet plugin.

    Plugin Author WC Lovers

    (@wclovers)

    NO, you may use code snippets for the purpose.

    Kindly show me screenshot, for which fields you want to apply this condition?

    Thread Starter VoN

    (@webdesignervon)

    Here’s a picture of the field I want to apply the condition to: https://imgur.com/LY02z03

    Here’s a picture of the content of the field: https://imgur.com/GFnctPw

    Thanks.

    Plugin Author WC Lovers

    (@wclovers)

    Sorry, it’s not possible to add such custom condition over custom fields.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Need to limit the characters of number field to just 10’ is closed to new replies.