Have an idea?

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

Numeric question forcing 2 decimal places

I found this JavaScript solution (thanks to Zachary) in amongst my older forum posts and it works. Forcing respondents to enter a numeric response to 2 decimal places always.
$(document).ready(function(){
    var response = $('#NumericQ').val();
    var regex = /\.[0-9][0-9]$/;
     
    if (!regex.test(response))
    {
        strErrorMessage = 'Error text here.';
    }
})

Now I want to add the "Not Applicable" question to the numeric response.

I was seeking a tweak to this script to allow the respondent to  ....

1/ Enter a numeric response with 2 decimal places OR
2/ Tick the check box.

Many thanks.
asked Oct 7 by Paul Moon Platinum (94,385 points)
Just a couple of further comments ...

I also needed to use this numeric question type with the Branching and Not Applicable tools from the questions library.

Worked a treat.
All the different types of phones is my fear as well.  It's hard to support iPhones because Apple's tech is totally unavailable outside Apple devices, it's harder to support Androids because there are just so many different devices, and it's hardest of all to support all the rest because they represent such a small percentage of users.

Glad to hear you have the script playing nicely with those other questions.
Thanks Zachary for the additional comments.

If you satisfy the iPhone world, you are more than half way there with mobile phones. I understand at least 60%+ of mobile phone users are iPhone customers.

So that's a good start.

Toss in the other devices (desktops, laptops, tablets, etc.) and you are well on your way.

Hard to say how many other mobile phones are working the way we want (or not)?
Doesn't your snippet satisfy iPhones at least?
Correct, yes it does.

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...