$(document).ready(function() { $("#od-font-test").click(function(){ $("body").css("font-family", "opendyslexic3regular") }); $('.test-code-input').keyup(function() { var input = $(this).val().split("-").join("").split("—").join(""); if (input.length > 0) { input = input.match(new RegExp('.{1,4}', 'g')).join("—"); } $(this).val(input); }); }); $('form[name=form-quiz-start]').submit(function(event) { var $form = $(this); var data = $form.serialize(); $.ajax({ url: window.location.pathname, type: 'POST', data: data, dataType: 'json', success: function(response) { var id = response.id window.localStorage.setItem('id', id); window.location.href = `/test/`; }, error: function(response) { error_response(response); } }); event.preventDefault(); }); function error_response(response) { const $alert = $("#alert-box"); $alert.html(''); if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) { $alert.html(`