How to sanitize a price input?

I have a form field where I input prices. The processing on my forms expects the input of the price to not contain currency symbols (in my case $) or commas. However often I am copying and pasting a price that is formatted like that (example: $3,000.00). How do I turn create a variable that takes the input of my price form field and deletes any "$" and "," before returning a sanitized result for processing?

Something like this should work:

Enter the price (we'll remove any $): {formtext: name=price; default=$100}
{sanitized_price=replace(price, "$", "")}
Sanitized price: {=sanitized_price}

1 Like

Your example removes the dollar symbol but it doesn't remove commas. Can you show me how that might be done?

Here you go, you can replace as many things as you want:

Enter the price (we'll remove any $ or ,): {formtext: name=price; default=$1,000}
{sanitized_price=replace(replace(price, "$", ""), ",", "")}
Sanitized price: {=sanitized_price}

1 Like

This works well. Thank you for taking the time to teach me.