Number length validation | XM Community
Skip to main content

Hi Expert,

 

In one of the survey question we have to enable a validation to check only the length of the entered numbers is 8. The length should not be less than or greater than 8.

 

Thank you,

Krishna.

Yes you can do this through custom validation

Refer to below link

https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/validation/

 


https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/validation/#ContentValidation


The validation did not helped. When i enabled maximum length 8 and this is not validating.And also i set to minimum length 8, it is allowing more than 8 length and allowing characters as well.

 

The answer needs to be validate only 8 digits of numbers. The length should not be less than 8 digit and not greater than 8 digit.

 

Thank you,

Krishna.

 


The validation did not helped. When i enabled maximum length 8 and this is not validating.And also i set to minimum length 8, it is allowing more than 8 length and allowing characters as well.

 

The answer needs to be validate only 8 digits of numbers. The length should not be less than 8 digit and not greater than 8 digit.

 

Thank you,

Krishna.

 

You can use the JS provided by TOMG in the following community post: 

 


@Krishna Prabhu 
You can set your custom validation to match this regex code: ^\d{8}$

More about custom validation: https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/validation/#CustomValidation

Let me know if it helps


The validation did not helped. When i enabled maximum length 8 and this is not validating.And also i set to minimum length 8, it is allowing more than 8 length and allowing characters as well.

 

The answer needs to be validate only 8 digits of numbers. The length should not be less than 8 digit and not greater than 8 digit.

 

Thank you,

Krishna.

 

Try this 

 


@dxconnamnguyen , Thanks for this. I am not able to follow. Could you please help to share the piece of JS code and add this validation?

 

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
    /*Place your JavaScript here to run when the page is fully displayed*/

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
    /*Place your JavaScript here to run when the page is unloaded*/

});

 

Thank you,

Krishna.


@Krishna Prabhu You don’t need any JS to solve this my dear. I’ve test this myself, forget about those guy, they just spam link out without any testing. Follow me

  1. Choose custom validation on the left side of your question 

     

  2. Choose your question, choose match regex and paste this in ^\d{8}$ 

     

This will allow only 8 number to pass throgh


Thanks. Let me test this completely and update you.


Leave a Reply