Skip to main content
Nintex Community Menu Bar
Question

Format phone number using custom field renderer snippet

  • July 10, 2024
  • 7 replies
  • 47 views

Forum|alt.badge.img+3

Good afternoon, I am attempting to format phone numbers “live” while users type, similar to how it works in the standard Salesforce environment. Essentially I would want to take user phone inputs like 1234567890 and automatically change that to (123) 456-7890. I have no significant experience with javascript so I’m not too sure where to start here. In an ideal world it would also take 123-456-7890 or variations like that and reformat that properly as well. Thinking about this, it also made me wonder if it could format extensions properly as well. Typically I like to use the format (123) 456-7890;123. Are there any “out of the box” solutions that can help on this front? I’m also open to solutions that don’t do it live (if that is too difficult), but instead do it after a save and refresh. Much appreciated as always for any help. Thanks, Dave

7 replies

Forum|alt.badge.img+5
  • July 10, 2024

You could include the jQuery mask plugin http://igorescobar.github.io/jQuery-Mask-Plugin/

And then give your field a class “phone” for example.

Then in an inline JS initialize it there with $(‘.phone input’).mask(‘(000) 000-0000’);


Forum|alt.badge.img+3
  • Author
  • July 10, 2024

Ok great, thanks Thimo. I guess the main question I have from that is how do I “include” the jQuery mask plugin. Do I have to download it from that site and then upload it as a component pack?


Forum|alt.badge.img+5
  • July 10, 2024

You can download it and upload it to the static resources.

Then you can link it in your skuid page.


Forum|alt.badge.img+5
  • Nintex Employee
  • July 10, 2024

Hi Dave,

The following post may also be of use to go through.

https://community.skuid.com/t/re-format-a-phone-number-using-custom-field-renderer



Forum|alt.badge.img+3
  • Author
  • July 10, 2024

Ok thanks Thimo. Here is where I am at right now. I hav e downloaded the ogrescobar jQuery Mask Plugin and uploaded the .zip as a static resource with public caching. I have then added the static resource to skuid and referenced the “jquery.inputmask.bundle.js” in the file path that skuid asks for. I then created a new inline (Snippet) called “newSnippet2” and used $(‘.phone input’).mask(‘(000) 000-0000’) in the snippet body. Then in a field editor, I have added the Account Phone field and used the css class “phone”. When I try to open that page, it does not load. Any idea where I might be going wrong here. Screenshots attached. Thanks as always. Dave fcc104a52f25952b0bb09b2ff59084a3a114e305.pngab2c7e09b0269d7fb37104072bb7e614f47a77b5.png


Forum|alt.badge.img+3
  • Author
  • July 10, 2024

I also attempted the inline JS code to read: $(‘.phone’).mask(‘(000) 000-0000’) That did not work either unfortunately


Forum|alt.badge.img+5
  • July 10, 2024

Have you tried an inline-JS that looks like this?

(function(skuid){ var $ = skuid.$;<br> $(document.body).one('pageload',function(){<br> &nbsp; &nbsp;&nbsp;$('.phone input').mask('(000) 000-0000');<br> });<br>})(skuid);


.phone input –> because the phone class gets added to a wrapper around the field in a field editor and not the input element directly. And inline-JS that it gets loaded on pageload.

Do you have any errors in the console?