Valid US State Options | XM Community
Skip to main content
I have one field in a text entry question that has "valid US state" as the validation. I need this to be the two-letter abbreviation. Is it possible to do this? I have searched and keep coming up empty. Thanks
If you want to make sure it is a valid two-letter abbreviation, why not make it a drop-down box where they select the abbreviation, instead of entering it as text?
This field is one of 7 in a text entry question. We are collecting contact information and their is a separate field for each item.

2 approaches come to mind. 1 is to use the "valid US state" validation and then limit the amount of characters that can be typed to 2 using JavaScript. The below would work for the 1st Form Field:

jQuery("#"+this.questionId+" input[type=text]").eq(0).attr("maxlength","2");

Another approach would be to use Custom Validation where the 1st Form Field matches the following regex:

[Aa][LlKkRrZz]|[Cc][AaOoTt]|[Dd][CcEe]|[Ff][Ll]|[GgLlPp][Aa]|[HhRr][Ii]|[Ii][DdLlNnAa]|[Kk][SsNn]|[Mm][EeDdAaIiNnSsOoTt]|[Nn][EeVvHhJjMmYyCcDd]|[Oo][HhKkRr]|[Ss][CcDd]|[Tt][NnXx]|[Uu][Tt]|[Vv][TtAa]|[Ww][AaVvIiYy]

 


Leave a Reply