Recently I used code from a blog by Xavier Vargas called "CRM Field Masking with JQuery" to handle the field masking for the telephone fields in our development system. The function works great and is very flexible being able to use in all types of fields for all types of formats.
I wanted to implement it on a current project for the telephone fields but was unable to since the telephone field had to also handle multiple international telephone formats. That’s when I got to thinking, how could I modify the field masking to handle domestic and multiple international telephone formats all within one telephone field?
After thinking for a bit, it seemed pretty easy. I had already turned the state and the country fields into a drop-down using code from the article CRM 2011: Making the state field a dropdown. Depending on the country I selected, I populated the telephone field with the respective country's phone format and populated it with the dial-out number and the country code.
NOTE: I also changed the JQuery Mask function so that I didn’t have ‘9’ as the mask value since 9 is used in country codes. You can choose what you want to replace ‘9.'
NOTE: I also changed the JQuery Mask function so that I didn’t have ‘9’ as the mask value since 9 is used in country codes. You can choose what you want to replace ‘9.'