Number length validation | XM Community
Solved

Number length validation

  • 11 September 2023
  • 9 replies
  • 324 views

Userlevel 2
Badge +2

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.

icon

Best answer by Nam Nguyen 11 September 2023, 15:48

View original

9 replies

Userlevel 5
Badge +10

Yes you can do this through custom validation

Refer to below link

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

 

Badge +30

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

Userlevel 2
Badge +2

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.

 

Badge +30

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: 

 

Userlevel 7
Badge +20

@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

Userlevel 5
Badge +10

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 

 

Userlevel 2
Badge +2

@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.

Userlevel 7
Badge +20

@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

Userlevel 2
Badge +2

Thanks. Let me test this completely and update you.

Leave a Reply