Skip to content

Instantly share code, notes, and snippets.

@mattbloomfield
Last active July 11, 2018 15:47
Show Gist options
  • Save mattbloomfield/fac63be414cbd4ed13839b2f62740cce to your computer and use it in GitHub Desktop.
Save mattbloomfield/fac63be414cbd4ed13839b2f62740cce to your computer and use it in GitHub Desktop.
Qualtrics.SurveyEngine.addOnload(function() {
var regex = /(my text string)|(my other text string)/gi;
var fieldName = 'FieldName';
// add listener to text boxes
jQuery('#' + this.questionId + ' textarea').on('blur', function() {
// Find the value typed in textbox
var value = jQuery(this).val();
if (value.match(regex)) {
// if matches then set a variable to 'true' and also store value for good measure
Qualtrics.SurveyEngine.setEmbeddedData(fieldName + '_Value', value)
Qualtrics.SurveyEngine.setEmbeddedData(fieldName, 'true')
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment