Validate phone number

  • ABPro Support
  • Topic Author
  • Offline
  • Moderator
  • Moderator
More
14 years 10 months ago - 14 years 10 months ago #1438 by ABPro Support
Validate phone number was created by ABPro Support
Because there are many different phone number formats around the world, ABPro does not validate what is entered.

If you want to validate for something like 403-555-1212 you could do this..

Edit fe_val.php

Look for:
if ($apptpro_config->requirePhone == "Yes" && $phone == "" ) {
		    $err = $err.JText::_('RS1_INPUT_SCRN_PHONE_ERR');
	}

Add this below it:
if(!ereg("^[0-9]{3}-[0-9]{3}-[0-9]{4}$", $phone)) {
		    $err = $err.JText::_('RS1_INPUT_SCRN_PHONE_ERR');
	}
Last edit: 14 years 10 months ago by ABPro Support.

Please Log in to join the conversation.

  • Frank Westerhout
  • Frank Westerhout's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • ABPro enthusiast
More
12 years 11 months ago - 12 years 11 months ago #7231 by Frank Westerhout
Replied by Frank Westerhout on topic Re: Validate phone number
With as an example for Dutch formatted phone numbers:

if(!ereg("^[0-9]{2,4}-[0-9]{6,8}$", $phone)) {
$err = $err.JText::_('RS1_INPUT_SCRN_PHONE_ERR');
}


Meaning: 2-4 numbers from 0-9 as the region code, a '-' as delimiter and 6-8 numbers from 0-9 as the phone number, for example: XX-XXXXXXXX or XXX-XXXXXXX or XXXX-XXXXXX

Frank

Give ABPro the boost it deserves :-)
Last edit: 12 years 11 months ago by Frank Westerhout.

Please Log in to join the conversation.

  • Frank Westerhout
  • Frank Westerhout's Avatar
  • Offline
  • Junior Boarder
  • Junior Boarder
  • ABPro enthusiast
More
12 years 7 months ago #8447 by Frank Westerhout
Replied by Frank Westerhout on topic Re: Validate phone number
Addendum on my previous post:

To prevent two of the same error messages at the frontend when the telephone field is empty:

1. Edit in fe-val.php at +/- line 82:

if ($apptpro_config->requirePhone == "Yes" && $phone == "" ) {
$err = $err.JText::_('RS1_INPUT_SCRN_PHONE_ERR');

Change it to:

if ($apptpro_config->requirePhone == "Yes" && $phone == "" ) {
$err = $err.JText::_('RS1_INPUT_SCRN_PHONE_ERR_EMPTY');

2. Add a NEW token in the frontend language file at +/- line 67:

RS1_INPUT_SCRN_PHONE_ERR_EMPTY="Check your input: The field 'Telephone' is empty!<br><br>"

With this small modification you prevent getting two of the same error messages when the customer has left the telephone field empy (only valid when you've add a second check in fe-val.php as explained in the previous post.

Cheers,

Frank

Give ABPro the boost it deserves :-)

Please Log in to join the conversation.

More
12 years 2 months ago #9808 by Lindsay Heyes
Replied by Lindsay Heyes on topic Re: Validate phone number
UK land-line phone numbers are tricky to validate, and worse if mobile phone numbers have to be allowed. I authored this Regular Expression, for use within the UK, to avoid being too prescriptive:

^[0][1-9][ 0-9]{7,12}$

It simply checks for the leading zero of the STD code and that the next digit is from 1 to 9, then checks that the rest of the characters are either spaces or digits and the number is the right length. This approach allows for common idiosyncracies and likely future number allocations, but stops someone just entering 999 or 11111111.

It will accept:
01234 567890
01234 567 890
01234 56 78 90
012 34 56 78 90
and so on.

It rejects +44 numbers.

It's worth bearing in mind when authoring Regular Expressions that ereg (now deprecated) does not accept \d for digits or \w for whitespace characters, so you have to use [0-9] and a literal space instead.

Please Log in to join the conversation.

  • Simon Štefanka
  • Simon Štefanka's Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • I hairstylist.. :)
More
8 years 5 months ago #20732 by Simon Štefanka
Replied by Simon Štefanka on topic Re: Validate phone number
Hi Rob
How I add validation numbers for SMS notification.
Is it possible?

Thanks

My official website https://mojsalon.sk/

Please Log in to join the conversation.

More
8 years 5 months ago - 8 years 5 months ago #20736 by Rob
Replied by Rob on topic Re: Validate phone number
There is no easy way to do that as the sms phone number is not included in the data passed to the validation routine.

You could edit the client side script, and server side validation call and mimic the way 'phone' is handled.
Client side
File: \components\com_rsappt_pro3\script.js
Function: function validateForm(NoCaptcha)
The sms phone number is in the html input id sms_phone on the booking screen.

Server side
File: \components\com_rsappt_pro3\fe_val.php
Last edit: 8 years 5 months ago by Rob.

Please Log in to join the conversation.

  • Simon Štefanka
  • Simon Štefanka's Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • I hairstylist.. :)
More
8 years 5 months ago - 8 years 5 months ago #20744 by Simon Štefanka
Replied by Simon Štefanka on topic Re: Validate phone number
Maybe if it was automatically inserted from field "phone".

Field "sms_phone" could be hidden.

Nonsense?

My official website https://mojsalon.sk/
Last edit: 8 years 5 months ago by Simon Štefanka.

Please Log in to join the conversation.

  • Simon Štefanka
  • Simon Štefanka's Avatar
  • Offline
  • Senior Boarder
  • Senior Boarder
  • I hairstylist.. :)
More
8 years 5 months ago - 8 years 5 months ago #20748 by Simon Štefanka
Replied by Simon Štefanka on topic Re: Validate phone number
Hi Rob.
Customer requests SMS notification (checkbox). Field "sms_phone" will be filled from field "phone". Field "phone" can be verified.

I'm not a programmer, so it's not perfect.
Line 27  add:
<script>
function Fillsms(f) {
  if(f.use_sms.checked == true) {
    f.sms_phone.value = f.phone.value;
  }
}
</script>

Line 77:   <div class="sv_table_cell_value"><input type="checkbox" name="use_sms" id="use_sms" onchange="checkSMS();" onclick="Fillsms(this.form)"/>

My official website https://mojsalon.sk/
Last edit: 8 years 5 months ago by Simon Štefanka.

Please Log in to join the conversation.

More
8 years 5 months ago #20749 by Rob
Replied by Rob on topic Re: Validate phone number
The only issue I see is that if the customer goes back and changes the phone number field after they checked the use_sms checkbox, the sms_phone will not get updated.

You might want to add and onChange to the phone field to update the sms_phone field.

Please Log in to join the conversation.

Time to create page: 0.135 seconds
Powered by Kunena Forum

Just thought I'd pass along some positive feedback from my client:
"All of us are excited about our new online booking!! Shanyn & Chelsea said it’s “fun”; even I’m getting the hang of it!  There are still a few glitches so we’re having another meeting on Tuesday - but all of us are thrilled!  Thank you! Thank you!"

The "glitches" they mentioned are all minor and I've tweaked a few settings and answered a few questions to address them. Overall they're very happy. "
Chris C


"Hi, im back 
 After using appbooking pro for 3 years successfully i have tried another booking system for a new site that was more expensive, promised a lot but full of errors and the developers wanted to suck the $$ for every little request.

Anyways, great to be back here "
roll82


"thanks for all the help you have given me over the past few months. We have managed to get the system to work so that multiple businesses around the country can log into our website and manage appointments for their own businesses through the ABPro System."

owen_molloy October 2013


Just thought I'd pass along some positive feedback from my client:
"All of us are excited about our new online booking!! Shanyn & Chelsea said it’s “fun”; even I’m getting the hang of it!  There are still a few glitches so we’re having another meeting on Tuesday - but all of us are thrilled!  Thank you! Thank you!"

The "glitches" they mentioned are all minor and I've tweaked a few settings and answered a few questions to address them. Overall they're very happy. "
Chris C


"Hi, im back 
 After using appbooking pro for 3 years successfully i have tried another booking system for a new site that was more expensive, promised a lot but full of errors and the developers wanted to suck the $$ for every little request.

Anyways, great to be back here "
roll82


"thanks for all the help you have given me over the past few months. We have managed to get the system to work so that multiple businesses around the country can log into our website and manage appointments for their own businesses through the ABPro System."

owen_molloy October 2013


Just thought I'd pass along some positive feedback from my client:
"All of us are excited about our new online booking!! Shanyn & Chelsea said it’s “fun”; even I’m getting the hang of it!  There are still a few glitches so we’re having another meeting on Tuesday - but all of us are thrilled!  Thank you! Thank you!"

The "glitches" they mentioned are all minor and I've tweaked a few settings and answered a few questions to address them. Overall they're very happy. "
Chris C


"Hi, im back 
 After using appbooking pro for 3 years successfully i have tried another booking system for a new site that was more expensive, promised a lot but full of errors and the developers wanted to suck the $$ for every little request.

Anyways, great to be back here "
roll82


"thanks for all the help you have given me over the past few months. We have managed to get the system to work so that multiple businesses around the country can log into our website and manage appointments for their own businesses through the ABPro System."

owen_molloy October 2013


Just thought I'd pass along some positive feedback from my client:
"All of us are excited about our new online booking!! Shanyn & Chelsea said it’s “fun”; even I’m getting the hang of it!  There are still a few glitches so we’re having another meeting on Tuesday - but all of us are thrilled!  Thank you! Thank you!"

The "glitches" they mentioned are all minor and I've tweaked a few settings and answered a few questions to address them. Overall they're very happy. "
Chris C


"Hi, im back 
 After using appbooking pro for 3 years successfully i have tried another booking system for a new site that was more expensive, promised a lot but full of errors and the developers wanted to suck the $$ for every little request.

Anyways, great to be back here "
roll82


"thanks for all the help you have given me over the past few months. We have managed to get the system to work so that multiple businesses around the country can log into our website and manage appointments for their own businesses through the ABPro System."

owen_molloy October 2013


Just thought I'd pass along some positive feedback from my client:
"All of us are excited about our new online booking!! Shanyn & Chelsea said it’s “fun”; even I’m getting the hang of it!  There are still a few glitches so we’re having another meeting on Tuesday - but all of us are thrilled!  Thank you! Thank you!"

The "glitches" they mentioned are all minor and I've tweaked a few settings and answered a few questions to address them. Overall they're very happy. "
Chris C


"Hi, im back 
 After using appbooking pro for 3 years successfully i have tried another booking system for a new site that was more expensive, promised a lot but full of errors and the developers wanted to suck the $$ for every little request.

Anyways, great to be back here "
roll82


"thanks for all the help you have given me over the past few months. We have managed to get the system to work so that multiple businesses around the country can log into our website and manage appointments for their own businesses through the ABPro System."

owen_molloy October 2013


Just thought I'd pass along some positive feedback from my client:
"All of us are excited about our new online booking!! Shanyn & Chelsea said it’s “fun”; even I’m getting the hang of it!  There are still a few glitches so we’re having another meeting on Tuesday - but all of us are thrilled!  Thank you! Thank you!"

The "glitches" they mentioned are all minor and I've tweaked a few settings and answered a few questions to address them. Overall they're very happy. "
Chris C


"Hi, im back 
 After using appbooking pro for 3 years successfully i have tried another booking system for a new site that was more expensive, promised a lot but full of errors and the developers wanted to suck the $$ for every little request.

Anyways, great to be back here "
roll82


"thanks for all the help you have given me over the past few months. We have managed to get the system to work so that multiple businesses around the country can log into our website and manage appointments for their own businesses through the ABPro System."

owen_molloy October 2013


Just thought I'd pass along some positive feedback from my client:
"All of us are excited about our new online booking!! Shanyn & Chelsea said it’s “fun”; even I’m getting the hang of it!  There are still a few glitches so we’re having another meeting on Tuesday - but all of us are thrilled!  Thank you! Thank you!"

The "glitches" they mentioned are all minor and I've tweaked a few settings and answered a few questions to address them. Overall they're very happy. "
Chris C


"Hi, im back 
 After using appbooking pro for 3 years successfully i have tried another booking system for a new site that was more expensive, promised a lot but full of errors and the developers wanted to suck the $$ for every little request.

Anyways, great to be back here "
roll82


"thanks for all the help you have given me over the past few months. We have managed to get the system to work so that multiple businesses around the country can log into our website and manage appointments for their own businesses through the ABPro System."

owen_molloy October 2013


Just thought I'd pass along some positive feedback from my client:
"All of us are excited about our new online booking!! Shanyn & Chelsea said it’s “fun”; even I’m getting the hang of it!  There are still a few glitches so we’re having another meeting on Tuesday - but all of us are thrilled!  Thank you! Thank you!"

The "glitches" they mentioned are all minor and I've tweaked a few settings and answered a few questions to address them. Overall they're very happy. "
Chris C


"Hi, im back 
 After using appbooking pro for 3 years successfully i have tried another booking system for a new site that was more expensive, promised a lot but full of errors and the developers wanted to suck the $$ for every little request.

Anyways, great to be back here "
roll82


"thanks for all the help you have given me over the past few months. We have managed to get the system to work so that multiple businesses around the country can log into our website and manage appointments for their own businesses through the ABPro System."

owen_molloy October 2013