Add valid markers to all fields modified by decitre search

This commit is contained in:
Gabriel Augendre 2018-06-15 23:32:48 +02:00
parent db8e68726b
commit 7187b11f15

View file

@ -16,9 +16,13 @@ document.addEventListener("DOMContentLoaded", function (event) {
document.querySelector('#id_isbn_invalid_feedback').style.display = 'none'; document.querySelector('#id_isbn_invalid_feedback').style.display = 'none';
document.querySelector('#id_title').value = data.title; document.querySelector('#id_title').value = data.title;
document.querySelector('#id_title').classList.add('is-valid');
document.querySelector('#id_authors').value = data.authors; document.querySelector('#id_authors').value = data.authors;
document.querySelector('#id_authors').classList.add('is-valid');
document.querySelector('#id_publication_year').value = data.year; document.querySelector('#id_publication_year').value = data.year;
document.querySelector('#id_publication_year').classList.add('is-valid');
document.querySelector('#id_price').value = data.price; document.querySelector('#id_price').value = data.price;
document.querySelector('#id_price').classList.add('is-valid');
var editorValue = ""; var editorValue = "";
var editorIsOther = false; var editorIsOther = false;
@ -33,13 +37,15 @@ document.addEventListener("DOMContentLoaded", function (event) {
} }
} }
document.querySelector('#id_editor').value = editorValue; document.querySelector('#id_editor').value = editorValue;
document.querySelector('#id_editor').classList.add('is-valid');
event = document.createEvent("HTMLEvents"); event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true); event.initEvent("change", true, true);
event.eventName = "change"; event.eventName = "change";
document.querySelector('#id_editor').dispatchEvent(event); document.querySelector('#id_editor').dispatchEvent(event);
if (editorIsOther) { if (editorIsOther) {
document.querySelector('#id_other_editor').value = data.editor document.querySelector('#id_other_editor').value = data.editor;
document.querySelector('#id_other_editor').classList.add('is-valid');
} }
}); });
}); });