How can I validate weight in increments of 5? | XM Community
Skip to main content
I'd like to get a user to enter their weight but only in 5 lb increments. Is there a way to set up the custom validation for this? Alternatively, is there a way of taking this data and processing it in a way automatically that rounds it to the closest fifth? Thanks!
Hi @JordanP,

you can use any regular expression to validate your task. Following one will do your task: `^\\d*[0|5]$`

Here you can find what particular symbols mean. In case you don't want to accept 0 or 5 only, just replace the `*` with `+`.

In case you don't know how to add a custom validation, see this. Your version should look like the one on the following image:



!





Regarding your alternative: it is also possible, but you'd probably have to use JavaScript. There are multiple possible solutions, which depend on when exactly you need to do this. In case you need it just for data processing, you could get your answer using piped text, round it and then send it to an embedded field. This way would enable you to store also your original values.

Leave a Reply