Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Limit zip code form field to 5 numeric characters

Avatar

Avatar
Validate 1
Level 1
wpomeroy
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
wpomeroy
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
wpomeroy
Level 1

11-11-2020

Is there a best practices way to do form field validation in ACC?  I would like to limit a zip code form field to 5 numeric characters and throwing an error message if the requirements are not met.  I've considered handling this via a split activity or JS but wasn't sure if there is a way to validate in the form activity itself.  Any insight would be appreciated.

Accepted Solutions (0)

Answers (3)

Answers (3)

Avatar

Avatar
Validate 1
MVP
Darren_Bowers
MVP

Likes

74 likes

Total Posts

252 posts

Correct Reply

81 solutions
Top badges earned
Validate 1
Affirm 50
Establish
Give Back 3
Applaud 25
View profile

Avatar
Validate 1
MVP
Darren_Bowers
MVP

Likes

74 likes

Total Posts

252 posts

Correct Reply

81 solutions
Top badges earned
Validate 1
Affirm 50
Establish
Give Back 3
Applaud 25
View profile
Darren_Bowers
MVP

11-11-2020

Hi @wpomeroy - you can use a number of techniques to validate input in the HTML input form. Here is some examples: https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation#Built-in_form_validation_exampl...

Cheers

Darren

Avatar

Avatar
Validate 1
Level 1
wpomeroy
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
wpomeroy
Level 1

Likes

0 likes

Total Posts

17 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
wpomeroy
Level 1

17-11-2020

Hello @_Manoj_Kumar , I tried this as well.  While it does limit the field to a maximum of 5 characters and removes non-numeric characters, the error that is generated is not user friendly (it errors out on submission rather than performing validation) and it also does not limit less than 5 characters.  I will make this change if there is no other solution but this does not seem best practices from a UX perspective.  Thanks.

Avatar

Avatar
Validate 1
MVP
_Manoj_Kumar
MVP

Likes

102 likes

Total Posts

300 posts

Correct Reply

96 solutions
Top badges earned
Validate 1
Contributor
Ignite 1
Shape 1
Give Back 5
View profile

Avatar
Validate 1
MVP
_Manoj_Kumar
MVP

Likes

102 likes

Total Posts

300 posts

Correct Reply

96 solutions
Top badges earned
Validate 1
Contributor
Ignite 1
Shape 1
Give Back 5
View profile
_Manoj_Kumar
MVP

11-11-2020

Hello @wpomeroy ,

 

You can change the data type in the schema to int.

To limit the length inform you can add a length attribute in the field.

length="5" 

 Thanks,

Manoj