Dodata nova pitanja, promenjena neka stara, dodate instrukcije
Dodata nova pitanja, promenjena neka stara, dodate instrukcije
This commit is contained in:
@@ -2,6 +2,18 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||
const form = document.querySelector('form');
|
||||
const formElements = form.elements;
|
||||
|
||||
const instructionsModal = new bootstrap.Modal(document.getElementById('instructionsModal'));
|
||||
instructionsModal.show();
|
||||
|
||||
document.getElementById('startModalBtn').addEventListener('click', function() {
|
||||
hideNavElementsAndQuestions();
|
||||
document.currentQuestion = 0;
|
||||
showQuestion('q0');
|
||||
setButtonVisiblity('next', true);
|
||||
setButtonVisiblity('back', true);
|
||||
setNextButtonAvailability();
|
||||
});
|
||||
|
||||
// Load saved form state
|
||||
/* loadFormState(formElements);
|
||||
|
||||
@@ -76,24 +88,32 @@ function setNextButtonAvailability() {
|
||||
const submitButton = document.getElementById('submit');
|
||||
// check if any input in the current question is checked, or filled in case it is a text input
|
||||
let nextEnabled = false;
|
||||
const inputs = currentQuestion.querySelectorAll('input, select, textarea');
|
||||
for (let input of inputs) {
|
||||
// if the input is not visible, skip it
|
||||
if (input.checkVisibility() === false) {
|
||||
continue;
|
||||
if (document.currentQuestion === 0) {
|
||||
const name = document.getElementById('name');
|
||||
const email = document.getElementById('email');
|
||||
if (name && email && name.value.trim() && email.value.trim()) {
|
||||
nextEnabled = true;
|
||||
}
|
||||
if (input.type === 'checkbox' || input.type === 'radio') {
|
||||
if (input.checked) {
|
||||
nextEnabled = true;
|
||||
break;
|
||||
} else {
|
||||
const inputs = currentQuestion.querySelectorAll('input, select, textarea');
|
||||
for (let input of inputs) {
|
||||
if (input.checkVisibility() === false){
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (input.value) {
|
||||
nextEnabled = true;
|
||||
break;
|
||||
if (input.type === 'checkbox' || input.type === 'radio') {
|
||||
if (input.checked) {
|
||||
nextEnabled = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (input.value) {
|
||||
nextEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nextButton.disabled = !nextEnabled;
|
||||
submitButton.disabled = !nextEnabled;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user