Discussions

 View Only
  • 1.  How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 16:05
    I have a field "Phone Number", I need the user to enter 10 digit phone number in the field. If the user enters digits less than or more than 10, it should display an error message. Is this possible using native functionality or needs some custom coding? I tried using Phone filed data type but it accepts any number of digits in the field. Any suggestions? 


  • 2.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 16:24
    Hi Raj,

    In the past when I have users that have run into this issue, for native functionality, I have typically made use of a formula field and a form rule to accomplish this for data entry on a form. For that to work I set up a field (In this example lets call it Phone Number Check) as a formula checkbox field. For the Phone Number Check field I used a formula of:

    If(Length([Phone Number])=10, True, False)

    What this means is this checkbox field only checks when the phone number is specifically 10 digits long. Then you can set up a form rule which checks to see if that Phone Number Check field is checked and if it is not checked then you can set it to Abort the Save and give them a warning message that they must use a phone number that is a valid length of 10 digits.


  • 3.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 16:46
    Hello Evan, thank you for the solution, I am not able to view the option of abort save though.


  • 4.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 17:07
    Hi Raj,

    In order to build a form rule you would want to open up the form to customize it and then select the Dynamic Form Rules tab. From there when creating a new rule you would want to set the condition to When the record is saved, and the Phone Number Check (or whatever field you want to check against) is not equal to checked, Then abort the save. I have included a screenshot below to show what an example form rule with this set up would look like.



  • 5.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 19:09
    Thank you, the abort save activates when you go for "The Record" option so could not view it earlier. There is one more problem, when you use the above method, 2 messages are displayed: 1st: The <formula check field> is not equal to true(according to my condition) 
    2nd : The custom message that I write. 

    how can you display just the custom message? _


  • 6.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 17:11
    Also, you may want to use a more elaborate check-box formula to handle entries containing non-digit characters and extraneous spaces. Something like the following, which handles up to five instances of a period, dash, parenthesis, or space entered as a separator between digits:

    var text p=ToText(Trim([Phone Number]));
    var text partOne=Part($p,1,".-)( ");
    var text partTwo=Part($p,2,".-)( ");
    var text partThree=Part($p,3,".-)( ");
    var text partFour=Part($p,4,".-)( ");
    var text partFive=Part($p,5,".-)( ");

    Length($partOne & $partTwo & $partThree & $partFour & $partFive) = 10


  • 7.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 19:40
    Can you please elaborate on the execution of the formula? As to, which formula field to use? I tried using the formula check box field and create the abort save option but it did not work. The formula field does not check when a 10 digit phone number is entered. 


  • 8.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 19:46
    Hi Raj,

    That formula Alex post does a more in depth look at the Length portion in order to do the Counting. It still needs the If statement that does the check for true and false. So something like

    var text p=ToText(Trim([Phone Number]));
    var text partOne=Part($p,1,".-)( ");
    var text partTwo=Part($p,2,".-)( ");
    var text partThree=Part($p,3,".-)( ");
    var text partFour=Part($p,4,".-)( ");
    var text partFive=Part($p,5,".-)( ");

    If(Length($partOne & $partTwo & $partThree & $partFour & $partFive) = 10, True, False)

    I believe should not just check the length of the number but check or uncheck that box for the form rule.


  • 9.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 20:02
    This definitely worked. Thank you


  • 10.  RE: How to limit a field ""Phone Number"" to only contain 10 digits?

    Posted 12-14-2017 19:07
    Thank you Alex, this helped.