Phone number format
					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
	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
- 
				JohnR
-   
- Posts: 64
- Joined: Sat Mar 03, 2018 11:44 pm
Phone number format
How can I edit a phone number so that the dashes appear when submitted in a form?
			
			
									
						
										
						- BaconFries
-   
- Posts: 6122
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Phone number format
It can done using regex see the following for Telephone Number Validation
Telephone Number Validation
Similar Question
Similar
			
			
									
						
										
						Telephone Number Validation
Similar Question
Similar
- 
				JohnR
-   
- Posts: 64
- Joined: Sat Mar 03, 2018 11:44 pm
Re: Phone number format
Where do you place the expression, e.g. /^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/
			
			
									
						
										
						- BaconFries
-   
- Posts: 6122
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Phone number format
In the Editbox properties you can set the validation data type to 'custom'
			
			
									
						
										
						- 
				JohnR
-   
- Posts: 64
- Joined: Sat Mar 03, 2018 11:44 pm
Re: Phone number format
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.
			
			
									
						
										
						in the Custom Expression box but it doesn't make any difference.
- Pablo
- Posts: 23904
- Joined: Sun Mar 28, 2004 12:00 pm
- Location: Europe
- Contact:
Re: Phone number format
There is no standard solution for this in HTML, this require a custom script.How can I edit a phone number so that the dashes appear when submitted in a form?
- BaconFries
-   
- Posts: 6122
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Phone number format
Sorry about that may be this will help 
https://stackoverflow.com/questions/278 ... ing-jquery
			
			
									
						
										
						https://stackoverflow.com/questions/278 ... ing-jquery
- 
				JohnR
-   
- Posts: 64
- Joined: Sat Mar 03, 2018 11:44 pm
Re: Phone number format
I checked the above link and ran the snippet. Now the question:
where do I place
Var Phone...
$('#phone'...
and
<script src...
			
			
									
						
										
						where do I place
Var Phone...
$('#phone'...
and
<script src...
- BaconFries
-   
- Posts: 6122
- Joined: Thu Aug 16, 2007 7:32 pm
Re: Phone number format
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: 64
- Joined: Sat Mar 03, 2018 11:44 pm
Re: Phone number format
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?
			
			
									
						
										
						Could it be because the phone number is in a FORM?

