Phone number check when write

Hi. Im new here. I have problem with phone numbers. I used this code to make Phone number type :

add_filter(
	'hivepress/v1/fields/phone/display_value',
	function($value){
		$listing = hivepress()->request->get_context('listing');

		if(!$listing){
			return $value;
		}

		// display phone number
		return preg_replace('~.*(\d{3})[^\d]{0,7}(\d{3})[^\d]{0,7}(\d{3})[^\d]{0,7}.*~', '+48 $1-$2-$3', $value);
	},
	1000
);

and it looks good, but I need to make an option when the user enters their own number in the form so that they cannot use more digits than are allowed in my country.

Another problem I have with display phone number. I use this code :

<button type="button" class="hp-listing__action hp-listing__action--message button button--large button--primary alt" data-component="link" data-url="tel:%value%">%icon% %value%</button>

But a button is not 100% width

numer

Sorry for my english.

Hi,

We recommend using this hook hivepress/v1/forms/listing_update and setting a value for the max_length field. As for the button, it is not the full width of the block, because in the secondary display area, the attributes are shown in two columns, and you need to change the CSS code and set 100% for these columns.

​I hope this is helpful to you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.