Ignore spaces in numerical validation | XM Community
Skip to main content

Hi all,
I am looking for a solution that allows a question to pass a numerical validation condition if there is also a space in the question. For example, the following question:
How many employees does your organisation have?
If I write an answer such as 40, but with a space in front or after the number, the validation won't pass. Is there some way around this issue?
Regards,
Michael

You can add this JS to take care of that:
Qualtrics.SurveyEngine.addOnReady(function () {
    let qc = this.questionContainer;
    document.querySelector("#NextButton").onclick = function () {
        qc.querySelectorAll(".InputText").forEach((input) => {
            input.value = input.value.trim();
        });
    };
});

The validation will still fail if there are spaces between numbers.


Leave a Reply