When you have survey pages with open text fields, it's possible for a survey respondent to submit the page by accidentally pressing the Enter key before completing their response. With this bit of code, you can ensure that won't happen!
Place this code in the theme of your survey.
- To do so go to the Style tab and scroll to the bottom of the survey preview to access the HTML/CSS Editor.
- Paste the following code below the existing HTML on the Custom HTML tab:
<script>
$(document).ready(function(){
$("form :input:not(textarea)").on("keypress", function(e) {
return e.keyCode != 13;
});
$("form :input:not(textarea)").on("keydown", function(e) {
return e.keyCode != 13;
});
});
</script>
This code works best when applied to the whole survey but could also be applied to a single page using a JavaScript action. If you choose to use the JavaScript action on an individual page, make sure you don't have the desktop interaction set to one at a time.
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 needs. Beyond this, check out our Professional Services; these folks have the scripting chops to help you to achieve what you are looking for!
Admin
— Bri Hillmer on 06/14/2016
@Amy: Thanks for the tip; great job problem solving! I'll add this to the documentation to help others!
Thanks for using our documentation and sending for your feedback!
Bri
Documentation Coordinator/Survey Sorceress
SurveyGizmo Customer Support
— Amy on 06/14/2016
In Style, make sure you don't have the desktop interaction set to one at a time. Needs to be set to standard in order for this javascript to work properly.