Making A Read Only Field

Important Update to Custom Scripting

SurveyGizmo's CustomScript Action now supports the LUA programming language. Visit our NEW Lua Scripting Resources!

Legacy Custom Scripting Language Deprecation Plans 

  1. New accounts (created after October 29, 2018) will only have the option to use Lua in scripts.
  2. As of October 29, 2018 Custom Scripting Actions will default to Lua as the scripting type in the Custom Scripting Action for accounts created before this date. You will be able to switch to the Legacy Custom Scripting; though we highly encourage using Lua.
  3. In the long term, Legacy Custom Scripting Actions will be switched to read-only. The exact date on this is to be determined; we will send notifications well ahead of time.

Many users like to use our default answer feature to pre-populate their survey. Often they wish to make this field appear as read only so that the respondent cannot change the answer. While this is not a built-in feature, we do have some easy-to-use JavaScript that allows you to make one of the following question types read only.

Please note that questions that have been set to disabled using the below scripts will not be able to be referenced via merge codes later in the survey.

Compatible Question Types:

Try it out in a survey: 

Check it out in an example survey!

OR

Add a survey with this setup to your account!

Setup

Once you have your survey set up you will use one of the following scripts below depending on your question type. To add this to your survey click Add New Action > JavaScript.

Textbox

This script will disable editing on a textbox with the CSS Class Name rotextbox. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a textbox question with the CSS class name "rotextbox" readonly
  $(".rotextbox :text").attr("readonly",true);
});

Essay

This script will disable editing on a essay with the CSS Class Name roessay. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes an essay question with the CSS class name "roessay" readonly
  $(".roessay").find("textarea").attr("readonly",true);
});

Checkbox

This script will disable editing on a checkbox with the CSS Class Name rocheckbox. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a checkbox question with the CSS class name "rocheckbox" readonly
  $(".rocheckbox :checkbox").attr("readonly",true);
});

Radio Button

This script will disable editing on a radio button with the CSS Class Name roradiobutton. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a radio button question with the CSS class name "roradiobutton" readonly  
  $(".roradiobutton :radio").attr("readonly",true);
});

Dropdown Menu

This script will disable editing on a dropdown menu with the CSS Class Name rodropdown. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a dropdown menu question with the CSS class name "rodropdownmenu" readonly
  $(".rodropdownmenu select").attr("readonly",true);
});

If you need to disable all the above question types you can copy this script and make sure to use the appropriate CSS Class Names to disable each question. Learn how to add a Class Name to your question.

$(document).ready(function(){
  // makes a textbox question with the CSS class name "rotextbox" readonly
  $(":text").attr("readonly",true);
  
  // makes an essay question with the CSS class name "roessay" readonly
  $(".roessay").find("textarea").attr("readonly",true);
  
  // makes a checkbox question with the CSS class name "rocheckbox" readonly
  $(".rocheckbox :checkbox").attr("readonly",true);
  
  // makes a radio button question with the CSS class name "roradiobutton" readonly  
  $(".roradiobutton :radio").attr("readonly",true);

  // makes a dropdown menu question with the CSS class name "rodropdownmenu" readonly
  $(".rodropdownmenu select").attr("readonly",true);
});

Scripting and Other Custom Solutions

We’re always happy to help you debug any documented script that is used as is. That said, we do not have the resources to write scripts on demand or to debug a customized script.

If you have customization ideas that you haven't figured out how to tackle, we're happy to be a sounding board for SurveyGizmo features and functionality ideas that might meet your customization. Beyond this, you might want to consult with someone on our Programming Services Team; these folks might have the scripting chops to help you to achieve what you are looking for!