Phone Number Validation Home › Forums › User Registration › Phone Number Validation Tagged: woocommerce validation This topic has 19 replies, 8 voices, and was last updated 4 months, 1 week ago by SaraAndrade. Viewing 15 posts - 1 through 15 (of 20 total) 1 2 → Author Posts November 26, 2018 at 11:02 pm #6762 MichaelParticipant Hi, is it possible to validate phone numbers? I’m using the Woocommerce integration addon and the Woocommerce “Phone” field has no input mask option. Would it work to user the advance field “Phone” and set “Field Name” to “billing_phone” In general, how can I adjust form field validations for fields (“input mask”)? Best, Michael November 27, 2018 at 4:51 am #6829 sanjeev3Member Hello, Currently, input mask is only available for phone field. Input masks on the billing and shipping phone fields are missing. We will introduce input masks to these fields soon. Adding billing_phone in the field name only doesnot work because the ‘user_registration_’ prefix will be added to all custom fields. However, you can add the billing_phone to the field name of phone field and donot add prefix with the following code. add_action( 'user_registration_fields_without_prefix', 'ur_add_no_prefix' ); function ur_add_no_prefix( $fields ) { $fields[] = 'phone'; return $fields; } Let me know if you have any further confusion. Regards, WPEverest Support November 27, 2018 at 5:23 pm #6845 MichaelParticipant Many thanks, but I just realized that input mask is not validation pattern like: ^\+?\d{0,13}. I would need a pattern, because there is a range of different phone number lengths. Is there any possibility to add html validation patterns? Furthermore, I would like to add woocommerce billing_title which should be a select with options like Mr. and Mrs. Because it is not available under woocommerce fields, I tried to use an extra select field and removing the prefix but it didn’t work with the following code: add_action( 'user_registration_fields_without_prefix', 'ur_add_no_prefix' ); function ur_add_no_prefix( $fields ) { $fields[] = 'select'; return $fields; } Maybe you could also add a woocommerce title field (‘billing_title’)? Best, Michael November 28, 2018 at 4:55 am #6870 sanjeev3Member Hello Michael, Yes. You can apply regex validation from backend. Client side regex validation is not available. This means the validation error message appears only after form submit. Here is the code: add_action( 'user_registration_validate_billing_phone','ur_validate_billing_phone',10,4); function ur_validate_billing_phone( $single_form_field, $data, $filter_hook, $form_id) { $field_label = isset( $data->label ) ? $data->label : ''; $value = isset( $data->value ) ? $data->value : ''; if( 1 === preg_match( '^\+?\d{0,13}^', $value ) ) { add_filter( $filter_hook, function ( $msg ) use ( $field_label ) { return __( $field_label . ' is an invalid phone number.', 'user-registration' ); }); } } billing_adddress_title is availalbe as an input field. The first Billing Address field under WooCommerce Billing Fields is a billing address title field. Select field is not available for title field. Thank You! November 29, 2018 at 6:15 pm #6994 artisanfxParticipant hi sorry first for my bad english but i try to explain as good as i can i have just install your plugin and it runs nicely and smooth on my site i have a question about the phone input section when new user register with name, address and telefon etc it adds all the information in the profile in a differend parts is there a way to add the phone number to a option in the user profile thats already was created before to it ? like to the data billing_phone = meta_key ? thank you November 29, 2018 at 6:25 pm #6996 artisanfxParticipant i see in the data base that the plugin use meta data -user_registration_number_box_1543450026 how can i add the phone to billing_phone data indeed not to user_registration_number_box_1543450026 November 30, 2018 at 4:26 am #7005 sanjeev3Member Hello artisanfx, If you already have the User registration WooCommerce add-on, you can get Billing Phone field with meta key billing_phone by default, you don’t need to tweak anything. If not, you can still follow above instructions. Drag the number field. change the it’s field key from number_box_1543450026 to billing_phone. And, with the code provided above, no prefix will be added and the meta key will only be billing_phone. Let me know if you mean something else. Regards, WPEverest Support November 30, 2018 at 11:37 am #7010 artisanfxParticipant yes i have seen the code above but sorry i am realy new in php may i ask you where do i need to add the code if you can point me in the right direction would be really great 🙂 thanks December 3, 2018 at 1:24 am #7112 artisanfxParticipant where do i need to set the code ? please help December 3, 2018 at 5:14 am #7168 sanjeev3Member Hey, you need to paste the codes in your child theme’s functions.php. Here is the tutorial for that: https://themegrill.com/blog/tutorial-creating-wordpress-child-theme/ If you are unfamiliar with these stuffs, please donot add anything, any errors may result your site to crash. This is more of the developers guide. Automatic option for this feature is not available. Regards, WPEverest Support December 3, 2018 at 11:53 am #7172 artisanfxParticipant thank you I will try this and thanks also for the warning but i add this on a test site first and will see if this works Warm Regards December 5, 2018 at 2:50 pm #7358 artisanfxParticipant i follow all the steps but this is not working for me 🙁 December 6, 2018 at 4:44 am #7396 sanjeev3Member Hello again, Can you please be more clear what you are trying to acheive. If you are trying to add billing_phone with custom number field? Add meta key billing_phone to the field name option, instead of number_1233432345 and the following codes to your child theme’s functions.php add_action( 'user_registration_fields_without_prefix', 'ur_add_no_prefix' ); function ur_add_no_prefix( $fields ) { $fields[] = 'number'; return $fields; } Hope this helps! Regards, WPEverest Support December 6, 2018 at 7:47 pm #7405 artisanfxParticipant yes i did this but it is not working for me maybe because i am using multiply themes on multiply domain anyway thanks for tying to help i think i need to make this manual copy and past it over in the profile of each user who will be new register on the page Thanks Regards artisanfx March 17, 2020 at 11:33 am #43035 geqesukyjParticipant If you are a developer and you need to validate a number which is using for the adding payment gate for international transaction. Then you have to do the custom essay writing services who will provide you the series of the validate numbers to your use. Author Posts Viewing 15 posts - 1 through 15 (of 20 total) 1 2 → You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In