Number length validation | XM Community
Skip to main content
Solved

Number length validation

  • September 11, 2023
  • 9 replies
  • 689 views

Forum|alt.badge.img+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.

Best answer by Nam Nguyen

@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

View original

9 replies

Forum|alt.badge.img+10
  • Level 4 ●●●●
  • 48 replies
  • September 11, 2023

Yes you can do this through custom validation

Refer to below link

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

 


Aanurag_QC
QPN Level 5 ●●●●●
Forum|alt.badge.img+31
  • 256 replies
  • September 11, 2023

Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 6 replies
  • September 11, 2023

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.

 


Aanurag_QC
QPN Level 5 ●●●●●
Forum|alt.badge.img+31
  • 256 replies
  • September 11, 2023
Krishna Prabhu wrote:

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: 

 


Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • 1091 replies
  • September 11, 2023

@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


Forum|alt.badge.img+10
  • Level 4 ●●●●
  • 48 replies
  • September 11, 2023
Krishna Prabhu wrote:

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 

 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 6 replies
  • September 11, 2023

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


Nam Nguyen
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+29
  • QPN Level 8 ●●●●●●●●
  • 1091 replies
  • Answer
  • September 11, 2023

@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


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 6 replies
  • September 11, 2023

Thanks. Let me test this completely and update you.