Hi Can someone guide how to ensure text entere is Alppha numeric of 21 characters.
Rock can you read JavaScript, this is what I used before to enforce a validation on phone number using JavaScript:
Qualtrics.SurveyEngine.addOnload(function () {
const qC = this.questionContainer;
const tempInput = qC.querySelector('.QuestionBody input');
try {
tempInput.type = 'tel';
tempInput.pattern = "\\\\d{10,12}";
tempInput.addEventListener('input',eL,false);
//console.log('ver: 88893');
} catch (err) {
console.log('change input type failed.');
}
});
function eL(e){
this.value = this.value.replace(/\\D/g,'');
if(this.value.length > 12){
this.value = this.value.substr(0,12);
}
/*
if ((this.value.length < 10) || (this.value.length > 12)){
console.log('not valid length');
}else{
console.log('valid length');
}
*/
}
Hi Rock you can use Regex validation for this. In your question settings, under Validation Type, select Custom Validation. Under choice, select "Click to select question text", and then in the next dropdown, select "Matches Regex". In the last box, enter your regex code.
I think this code will do it, but you can use this regex tester if you need to: ([a-zA-Z0-9]{21})
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.