From a03dc89195bd750760b8ad679e5c949c2d95aec7 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Mon, 28 Sep 2015 16:54:29 +0200 Subject: [PATCH] Corrected javascript verification of the form --- controllers/prototype/views/user_study.jade | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/controllers/prototype/views/user_study.jade b/controllers/prototype/views/user_study.jade index 823e312..654dd5d 100644 --- a/controllers/prototype/views/user_study.jade +++ b/controllers/prototype/views/user_study.jade @@ -34,8 +34,9 @@ block content alert('Select a correct date for the last time you played please'); return false; } + return true; } - form#form.form-signin(method="POST", action='/identification', onsubmit='return validateForm()') + form#form.form-signin(method="POST", action='/identification') h2 Please sign in label(for='inputId').sr-only Id input#inputId.form-control(name="inputId", type="text", placeholder='Id', required, autofocus) @@ -92,7 +93,13 @@ block content button#submitButton.btn.btn-lg.btn-primary.btn-block(type='submit') Sign in script. - document.getElementById('submitButton').onclick = function() { + document.getElementById('submitButton').onclick = function(event) { + event.preventDefault(); document.getElementById('submitButton').disabled = true; - document.getElementById('form').submit(); + if (validateForm()) { + console.log("Ok"); + document.getElementById('form').submit(); + } else { + document.getElementById('submitButton').disabled = false; + } }