Expand my Community achievements bar.

SOLVED

Phone number validation...

Avatar

Level 4

Is there a way to allow the user to input their phone number how they see fit and have it format it once it has been entered to your specs? For example, the user could input any of the following:

     5555555555

     555-555-5555

     555.555.5555

     (555) 555-5555

     (555) 555.5555

And it would format to display

     (555) 555-5555

Would it be a script or is there a way to do it within the validation pattern? Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can do all that with the Display, Edit and Validation patterns. You need to use a text field.

For the Display pattern use the pre-made Phone Number pattern: text{'('999')' 999-9999}

For the Edit pattern use multiple options separated by the pipe character.

text{'('999')' 999-9999}|text{9999999999}|text{999.999.9999}|text{999-999-9999}|etc.

And then you can put the same pattern as the Display pattern into the Validation pattern if you want an error to be generated if the number doesn't match the pattern.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

You can do all that with the Display, Edit and Validation patterns. You need to use a text field.

For the Display pattern use the pre-made Phone Number pattern: text{'('999')' 999-9999}

For the Edit pattern use multiple options separated by the pipe character.

text{'('999')' 999-9999}|text{9999999999}|text{999.999.9999}|text{999-999-9999}|etc.

And then you can put the same pattern as the Display pattern into the Validation pattern if you want an error to be generated if the number doesn't match the pattern.