Phone number format

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
IMPORTANT NOTE!!

DO YOU HAVE A QUESTION OR PROBLEM AND WANT QUICK HELP?
THEN PLEASE SHARE A "DEMO" PROJECT.



PLEASE READ THE FORUM RULES BEFORE YOU POST:
http://www.wysiwygwebbuilder.com/forum/viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
Post Reply
JohnR
 
 
Posts: 62
Joined: Sat Mar 03, 2018 11:44 pm

Phone number format

Post by JohnR »

How can I edit a phone number so that the dashes appear when submitted in a form?
User avatar
BaconFries
 
 
Posts: 5653
Joined: Thu Aug 16, 2007 7:32 pm

Re: Phone number format

Post by BaconFries »

It can done using regex see the following for Telephone Number Validation
Telephone Number Validation
Similar Question
Similar
JohnR
 
 
Posts: 62
Joined: Sat Mar 03, 2018 11:44 pm

Re: Phone number format

Post by JohnR »

Where do you place the expression, e.g. /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/
User avatar
BaconFries
 
 
Posts: 5653
Joined: Thu Aug 16, 2007 7:32 pm

Re: Phone number format

Post by BaconFries »

In the Editbox properties you can set the validation data type to 'custom'
JohnR
 
 
Posts: 62
Joined: Sat Mar 03, 2018 11:44 pm

Re: Phone number format

Post by JohnR »

I set the Data Type to 'Custom' and placed /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/
in the Custom Expression box but it doesn't make any difference.
User avatar
Pablo
 
Posts: 22503
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Phone number format

Post by Pablo »

How can I edit a phone number so that the dashes appear when submitted in a form?
There is no standard solution for this in HTML, this require a custom script.
User avatar
BaconFries
 
 
Posts: 5653
Joined: Thu Aug 16, 2007 7:32 pm

Re: Phone number format

Post by BaconFries »

Sorry about that may be this will help
https://stackoverflow.com/questions/278 ... ing-jquery
JohnR
 
 
Posts: 62
Joined: Sat Mar 03, 2018 11:44 pm

Re: Phone number format

Post by JohnR »

I checked the above link and ran the snippet. Now the question:
where do I place
Var Phone...

$('#phone'...
and
<script src...
User avatar
BaconFries
 
 
Posts: 5653
Joined: Thu Aug 16, 2007 7:32 pm

Re: Phone number format

Post by BaconFries »

Place the following between the <head></head> in Page HTML then change the ID of the input "Editbox" to phone

Code: Select all

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script>
$('#phone').focusout(function() {

  function phoneFormat() {
    phone = phone.replace(/[^0-9]/g, '');
    phone = phone.replace(/(\d{3})(\d{3})(\d{4})/, "($1) $2-$3");
    return phone;
  }
  var phone = $(this).val();
  phone = phoneFormat(phone);
  $(this).val(phone);
});
</script>
JohnR
 
 
Posts: 62
Joined: Sat Mar 03, 2018 11:44 pm

Re: Phone number format

Post by JohnR »

I tried this with the PAGE HTML and it doesn't seem to work.
Could it be because the phone number is in a FORM?
Post Reply