Allow Input and display of numbers


I’m working on a test and i want to allow respondtes to give their Wellingness to pay for a product in form of e.g. “5,99”
Goal: I want to have a code component to allow the respondents to input :

  • numbers (from 1 to 9)
  • comma(,)
  • and Backspace for the deletion of a number
    Furthermore i want these numbers to be displayed on the screen after beeing entered by the respondnts. At the end the final combination (e.g. 5,99) should be saved to the CSV Data file.

I have searched for similar topics here but i could not found any that adresses this issue.
Can someone please help me to write this code?

Thank you

Have a look at how I’ve coded the Age routine in my template

Best wishes,


Hello @wakecarter thank you for your response!

Your code Component worked perfectly for me. However i wanted to allow respondents to type digits and separate these with a comma “,” , do you have any idea how to allow input of a comma?
I have tried to add the following to your code :

elif ',' in keys:
    captured_string = captured_string+','

but this was not working.

Thank you

You need something like elif ‘COMMA’ in keys:

yes that worked!

Thank you very much for your help!