Skip to content

Commit

Permalink
Fixed issue #19392: Partial missing frontend validation on subquestio…
Browse files Browse the repository at this point in the history
…n codes (#3729)
  • Loading branch information
Shnoulle committed Feb 15, 2024
1 parent 75dbadc commit c189adf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions application/views/questionAdministration/subquestionRow.twig
Expand Up @@ -33,6 +33,7 @@
value="{{ subquestion.title|escape('html_attr') }}"
required='required'
maxlength="20"
pattern="[a-zA-Z0-9]+"
{% if question.survey.active == 'Y' %}
readonly="readonly"
{% endif %}
Expand Down Expand Up @@ -67,6 +68,7 @@
value="{{ subquestion.title|escape('html_attr') }}"
required='required'
maxlength="20"
pattern="[a-zA-Z0-9]+"
{% if question.survey.active == 'Y' %}
readonly="readonly"
{% endif %}
Expand Down
14 changes: 10 additions & 4 deletions assets/scripts/admin/questionEditor.js
Expand Up @@ -1826,6 +1826,16 @@ $(document).on('ready pjax:scriptcomplete', function () {
return false;
}
const saveWithAjax = target.dataset.saveWithAjax === 'true';
const form = document.getElementById('edit-question-form');
if (!(form instanceof HTMLFormElement)) {
throw 'form is not HTMLFormElement';
}
/* Check if input are HTML5 valid */
if (!form.checkValidity() ) {
// the form is invalid : show invalid part
form.reportValidity();
return false;
}

const firstSubquestionRow = document.querySelector('.subquestions-table tr');
if (firstSubquestionRow) {
Expand All @@ -1844,10 +1854,6 @@ $(document).on('ready pjax:scriptcomplete', function () {
}

const updateQuestionSummary = () => {
const form = document.getElementById('edit-question-form');
if (!(form instanceof HTMLFormElement)) {
throw 'form is not HTMLFormElement';
}
$.ajax({
url: form.dataset.summaryUrl,
method: 'GET',
Expand Down

0 comments on commit c189adf

Please sign in to comment.