How can I have conditional logic if a number is in a certain position in a string of numbers

  • Admore
    Asked on August 29, 2020 at 1:18 PM

    I am trying to make it so that when a customer types in their serial number...the 6th digit will determine the conditional logic. Is this possible? 

    Example:

    "AA001745" is an example where the "7" mean it was manufactured in 2017 ("6" would mean 2016, etc.).

    "5" = 10% off

    "6" = 20% off

    "7" = 30% off

    "8" = 40% off

    "9" or "0" = 50% off

  • KrisLei Jotform Support
    Replied on August 29, 2020 at 3:33 PM

    Hi,

    To my understanding, you would like to extract the substrings and create conditions based on the user's input, correct? It seems that you would need to use the Substring widget: https://www.jotform.com/widgets/substring 

    This widget can capture the characters between two positions in the typed text, in this way you can extract the 6th digit from the input field to the Substring widget up to the 6th character.

    1598729439widget Screenshot 10

    Then create conditions to Update or Calculate a field based on the last digit from the Substring widget, here's an example:

    1598729559condition Screenshot 21

  • KrisLei Jotform Support
    Replied on August 29, 2020 at 3:38 PM

    My apologies, it seems that my previous answer is cut off. 

    Here's a demo form: https://form.jotform.com/202415546909963 

    I have only created a condition for 2017 or if the code ends with seven, and here's a guide for the conditions: How to Insert Text or Calculation into a Field Using Conditional Logic

    Here's also an additional reference: How-to-Add-a-Widget-to-Your-Form

    I hope this helps. Let us know if you need further assistance.