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.

Resolved
13 replies