|
|
@ -42,20 +42,22 @@ function validateFormInput(event) { |
|
|
const form = document.getElementById('questionForm'); |
|
|
const form = document.getElementById('questionForm'); |
|
|
const submitBtn = document.getElementById('questionSubmitButton'); |
|
|
const submitBtn = document.getElementById('questionSubmitButton'); |
|
|
|
|
|
|
|
|
form.addEventListener('submit', e => { |
|
|
|
|
|
// If no radio in the group is checked…
|
|
|
|
|
|
if (!form.querySelector('input[type=radio]:checked')) { |
|
|
|
|
|
e.preventDefault(); // stop the form from submitting
|
|
|
|
|
|
submitBtn.classList.remove('wiggle'); // reset so the animation can retrigger
|
|
|
|
|
|
void submitBtn.offsetWidth; // force reflow (quick trick)
|
|
|
|
|
|
submitBtn.classList.add('wiggle'); // start the wiggle
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
if (form) { |
|
|
|
|
|
form.addEventListener('submit', e => { |
|
|
|
|
|
// If no radio in the group is checked…
|
|
|
|
|
|
if (!form.querySelector('input[type=radio]:checked')) { |
|
|
|
|
|
e.preventDefault(); // stop the form from submitting
|
|
|
|
|
|
submitBtn.classList.remove('wiggle'); // reset so the animation can retrigger
|
|
|
|
|
|
void submitBtn.offsetWidth; // force reflow (quick trick)
|
|
|
|
|
|
submitBtn.classList.add('wiggle'); // start the wiggle
|
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// Tidy up the class once the animation ends
|
|
|
|
|
|
submitBtn.addEventListener('animationend', () => { |
|
|
|
|
|
submitBtn.classList.remove('wiggle'); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
// Tidy up the class once the animation ends
|
|
|
|
|
|
submitBtn.addEventListener('animationend', () => { |
|
|
|
|
|
submitBtn.classList.remove('wiggle'); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|