Submission Validation with the Crowd Template on MTurk

♀尐吖头ヾ 提交于 2019-12-23 13:09:39

问题


I have a mturk survey and would like to validate the results when clicking the submit button. I found out there is one way discussed here. However, that does not seem to work. Does anyone have any idea?

My code (JS part):

<script type="text/javascript">
window.onload = function() {document.getElementById('submitButton').setAttribute('onclick', 'return validateForm()'); }

function validateForm() {
    alert("test");
    return false;
}

There is no alert and the submission succeeded.


回答1:


With the new Crowd HTML Elements, you can hook into the submit event and do your pre-validation like this:

document.querySelector('crowd-form').onsubmit = function(e ) {
    if (!validateForm()) {
        e.preventDefault();
    }
}

Thank you,

Amazon Mechanical Turk



来源:https://stackoverflow.com/questions/54266891/submission-validation-with-the-crowd-template-on-mturk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!