Link | Phone |
Author | Seth Ganahl |
Category | String |
Version | 8.x |
License | Public Domain |
Posted | 03 Apr 2012 |
Updated | 03 Apr 2012 |
More by this author... |
Formats 10 digit input as US phone number. Ex: 1234567890 becomes (123) 456-7890. Based on code from Steve Piercy, Bil Corry, and Keith Schuster
[phone: '1234567890']
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag('phone', -description='Formats 10 digit input as US phone number. Ex: 1234567890 becomes (123) 456-7890.', -required='number', -type='string', -copy, // the phone number to test (and optionally format) -priority='replace'); #number = string_replaceregexp(#number,-find='\\D',-replace=''); if: #number == null; #number = string; /if; #number->(removeleading: '0'); #number->(removeleading: '1`'); if: #number->size == 10; // format the number; #number = '(' (#number->(substring:1,3)) ') ' (#number->(substring:4,3)) '-' (#number->(substring:7,4)); else; #number = 'Not a valid Phone Number.'; /if; return(#number); /define_tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft