Jump to content

Registration - "Telephone numbers must be numeric only"


grafis
 Share

Recommended Posts

Anyone know how to update the Registration page to warn users what the required field formatting requirements are?

Specifically the Telephone field seems to cause issues requiring "numeric only". Folks in the united states tend to use (111) 222-3333, 111 / 222 3333, 111-222-3333 or similar delimiter type formatting that a human can parse.

How can I help users register more smoothly as basically all are rejected on their first try?

tia,

g

Link to comment
Share on other sites

You can either edit the templates, the language variables which show up on the templates, or edit the PHP code so that the requirement does not exist, which is what I did on my site.

in includes/content/reg.inc.php, find the section that looks like:

	if ($_POST['skipReg']==1 && (empty($_POST['firstName']) || empty($_POST['lastName']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['add_1']) || empty($_POST['town']) || empty($county) || empty($_POST['postcode']) || empty($_POST['country']))) {

	

		$errorMsg = $lang['reg']['fill_required'];

	

	} elseif(!isset($_POST['skipReg']) && (empty($_POST['firstName']) || empty($_POST['lastName']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['add_1']) || empty($_POST['town']) || empty($county) || empty($_POST['postcode']) || empty($_POST['country']) || empty($_POST['password']) || empty($_POST['passwordConf']))) {
This section defines which fields are required.  If you want to change the required fields, edit this to either add or remove fields from the list.



Next, to change the format requirements of the phone and mobile phone fields, look for this code:


	} elseif(!preg_match('#^([0-9-\s]+)$#', $_POST['phone'])) {

	

		$errorMsg = $lang['reg']['enter_valid_tel'];

	

	} elseif(!empty($_POST['mobile']) && !preg_match('#^([0-9-\s]+)$#', $_POST['mobile'])) {

	

		$errorMsg = $lang['reg']['enter_valid_tel'];

You can either edit this to your liking, or remove it completely, which is what I did.

Link to comment
Share on other sites

Guest estelle

What Burgensteen said. Plus, when adding the parentheses they may have to be escaped with backslashes (?). Try this:

	} elseif(!preg_match('#^([0-9-\s\(\)]+)$#', $_POST['phone'])) {

	

		$errorMsg = $lang['reg']['enter_valid_tel'];

	

	} elseif(!empty($_POST['mobile']) && !preg_match('#^([0-9-\s\(\)]+)$#', $_POST['mobile'])) {

	

		$errorMsg = $lang['reg']['enter_valid_tel'];

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...