web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Entering a SSN has nev...
Power Apps
Unanswered

Entering a SSN has never been solved

(0) ShareShare
ReportReport
Posted on by 1,259 Moderator

If anyone has a simple solution that will allow the user to enter a social security number and have it automatically add the "-" please let me know.

 

I don't believe this has ever been solved.  @mdevaney posted a solution that works for US phone numbers, but this solution is very complicated for what it does and the killer of it is it won't allow for a number that starts with a 0, which some social securities do.

 

Therefore, I'm wondering does everyone else just have the users either:

A.  Enter just the number

Or

B. Enter it as text and required them to type the hyphens.

 

I've searched and if there is a simple way to do this without sliders, timers, etc. I would LOVE to see it posted here.  The fact that PowerApps doesn't support Input masking as a property is a big miss by MS.  The fact that it hasn't been fixed is sad.

 

Thanks!

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @subsguts ,

    One way would be to do the following - set the format to Text and DelayOutput to true then OnSelect as well as on the end of your save code (and anywhere else you need to reset it)

    UpdateContext({varSSN: Blank()})

    Default

    varSSN

    If this is in a Form and you want to also show the current value

    Coalesce(
     varSSN,
     ThisItem.YourFieldName
    )

    OnChange

    If(
     IsNumeric(Self.Text) && Len(Self.Text) = 9,
     UpdateContext(
     {
     varSSN: Left(
     Self.Text,
     3
     ) & "-" & Mid(
     Self.Text,
     4,
     2
     ) & "-" & Right(
     Self.Text,
     4
     )
     }
     );
     Reset(Self)
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • leonsig93 Profile Picture
    229 on at

    Do you need it to get formatted as they input it or just need it formatted in your dataset?

     

    I managed to get something simple, though not as fancy as the auto-format. Also not sure if this is what your looking for/if it would work.

     

    I set up two fields, one text input and then a text label.

    In the text input just set MaxLength to 9, set a the OnChange property to Set(gvarFormat, true) and set DelayOutput to true. Did that to try and somewhat simulate the auto format. gvarFormat is just so the formatted display field doesn't just show --.

     

    In the Text control, I set this as the value:

    If(
     gvarFormat = false,
     "",
     Concatenate(
     Left(
     txtSocial_Input.Value,
     3
     ),
     "-",
     Mid(
     txtSocial_Input.Value,
     4,
     2
     ),
     "-",
     Right(
     txtSocial_Input.Value,
     4
     )
     )
    )

     

    So you get this:

    leonsig93_0-1717642768787.png

    Just gotta reset the gvarFormat to false for the next social. OnChange can be a bit weird so it might look funky if they type slowly but it'll get the job done. You could even hide the formatted field and just use it for your patch or form control's Update property.. Wit patch, you could just write that formula directly in and just not have the display field.

     

    I also sort of got it to be automatic, but it gets real weird if they don't type it all at once. Would probably need to add a timer delay but like you said that also opens up a whole different can of crazy.

     

  • Verified answer
    leonsig93 Profile Picture
    229 on at

    Wait I might have figured it out?

     

    So, its definitely a strange way to do it. But no timers or sliders or anything.

     

    Definitely needs some variables that have to get reset after each social that you add.

     

    So you take a Text Input control (using modern) and set the following properties:

    MaxLength = If(gvarFormatted = "", 9, 11)
    DelayOutput = true
    Value = gvarFormatted
    OnChange = 
    Set(
     gvarFormat,
     true
    );
    If(
     Len(Self.Value) = 9,
     Set(
     gvarFormatted,
     Concatenate(
     Left(
     Self.Value,
     3
     ),
     "-",
     Mid(
     Self.Value,
     4,
     2
     ),
     "-",
     Right(
     Self.Value,
     4
     )
     )
     )
    )

     This way if you slowly input the social the field doesn't bug out cause it'll wait till it sees 9 numbers. Then it formats it and that changes the MaxLength to account for the dashes.

    Couple digits

    leonsig93_1-1717643865450.png

    then the time it took me to screenshot and paste it over here and add the last 4

    leonsig93_2-1717643901444.png

    You just need to add a button or something that has this in it:

    OnSelect = Set(gvarFormat, false);Set(gvarFormatted, ""); Reset(txtSocial_Input_1)

    txtSocial_Input_1 is just the name of my Text Input. 

  • leonsig93 Profile Picture
    229 on at

    Didn't see this since I had the editor open,  my bad @WarrenBelz  😅

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @leonsig93 (I assume you are also @subsguts ,

    I did not bother with the MaxLength as it only triggers on 9 numeric characters (I see you have deleted the Numeric test), but yes, the Boolean Variable is another slightly different way of doing it. I am not into Modern Controls at this point, but if it works for you, that is good. I assume this is now solved ?

  • leonsig93 Profile Picture
    229 on at

    Hey @WarrenBelz , no I'm a different user. I was writing up my post while testing how to do it and didn't notice you had already replied cause I hadn't refresh the page in a while 😅.

     

    Didn't think to add validation to make sure they only input numbers.

  • subsguts Profile Picture
    1,259 Moderator on at

    Thanks @WarrenBelz and @leonsig93 , I'm just now waking up (different time zone :-)) to all these responses so I'm going to check it out this morning.

  • Verified answer
    EddieE Profile Picture
    4,641 Moderator on at

    @subsguts 

    This video gives some further ideas

    https://www.youtube.com/watch?v=povxwFZ4yik

     

    Using it, I got this working - which isn't quite there

    // Add a TextInput
    // Format
    Text
    
    // Default
    varTempTextInput
    
    // OnChange
    UpdateContext({varTempTextInput: Text(Value(Self.Text), "0##-##-####")})
    
    

     

    This can solve the '0' issue you mention but needs some work to manage number of values entered.

     

    Hope it can help?

     

     

     

     

  • subsguts Profile Picture
    1,259 Moderator on at

    @WarrenBelz I finally got to try this.  I used the varSSN as the Default to keep it simple to start.  I type in my SSN and when I leave the field it clears it.  I put a label above it and set it to the varSSN, which shows the SSN formatted, but I'm not sure what I did wrong so that it clears the Text Input field.

     

    Before I move to the next field:

    subsguts_0-1717725753734.png

    After I move to the next field:

    subsguts_1-1717725829358.png

    Any ideas?  Thanks

  • subsguts Profile Picture
    1,259 Moderator on at

    I'm going to try out all the solutions offered and if they all work then I'll mark all of them as solutions.  As we all know there is always more than one way to skin the PowerApps cat 🙂 lol

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard