]> _ Git - fluidbook-toolbox.git/commitdiff
fix #3945 @0.75
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 13 Oct 2020 08:28:51 +0000 (10:28 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 13 Oct 2020 08:28:51 +0000 (10:28 +0200)
resources/quiz/js/main.js

index f2190995003de04d1a7c0485b4ebe310ab650be7..4e6874d852a8f2b128ac02cdd54c45cf99db7bb9 100644 (file)
                         q.addClass('multiple');
                     }
                 } else if (type === 'text' || type === "email") {
-                    $(holder).append('<input type="' + type + '" name="answer" class="focusme" placeholder="' + $(this).attr('placeholder') + '" />')
+                    $(holder).append('<input required type="' + type + '" name="answer" class="focusme" placeholder="' + $(this).attr('placeholder') + '" />')
                 } else if (type === 'textarea') {
-                    $(holder).append('<textarea name="answer" class="focusme" placeholder="' + $(this).attr('placeholder') + '"></textarea>')
+                    $(holder).append('<textarea required name="answer" class="focusme" placeholder="' + $(this).attr('placeholder') + '"></textarea>')
                 }
 
                 $(q).find('.answers').append($(holder));
 
         function validateMulti(button) {
             var question = $(button).closest('.question');
+            if ($(question).find('input').length > 0) {
+                var input = $(question).find('input');
+                if (!$(input).get(0).checkValidity()) {
+                    $(input).get(0).reportValidity()
+                    return;
+                }
+            }
             var ok = true;
             $(question).find('.answer').each(function () {
                 if (($(this).attr('data-correct') == '1') != $(this).hasClass('active')) {