Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Restricting an open-end to only accept two letter abbreviations, and change to uppercase on-the-fly

I have an open-end question in my survey called "State".  I want to restrict the input so you can only type in a two-letter abbreviation. I don't need to verify that those are valid state code, I just need to have two letters. Plus, I want to make sure they only enter in upper-case letters. So if they type in lower-case letters it automatically changes them to upper-case letters. Does anyone have some magic code to make that work for me?
asked Aug 7, 2019 by anonymous

1 Answer

+1 vote
Best answer
If you're using Lighthouse Studio  9, try placing the following jQuery code someplace in your "State" question.

<script type="text/javascript">
   $(document).on("ssi_ready", function() {
      $("#State").keyup(function() {
         var test = /[A-Z]{2}/;
         if(!test.test($(this).val())) {
            $(this).val($(this).val().replace(/[^a-zA-Z]/g, "").toUpperCase());
answered Aug 7, 2019 by Nathan Bryce Silver Sawtooth Software, Inc. (9,380 points)