From 1c88896d2f4f1cd7c037cadaf6c7fdc3bf52aa86 Mon Sep 17 00:00:00 2001 From: "Mark M. Florida" <markflorida@wustl.edu> Date: Wed, 26 Oct 2016 18:30:28 -0500 Subject: [PATCH] XNAT-4242: form validation errors will stop submission and display a dialog listing fields that need to be corrected. --- src/main/webapp/scripts/xnat/xhr.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/main/webapp/scripts/xnat/xhr.js b/src/main/webapp/scripts/xnat/xhr.js index 5f3754f4..b6acb280 100755 --- a/src/main/webapp/scripts/xnat/xhr.js +++ b/src/main/webapp/scripts/xnat/xhr.js @@ -578,16 +578,17 @@ var XNAT = getObject(XNAT||{}), // stop here if there are errors if (errors.length) { console.log('ERRORS: ' + errors); - // errors = errors.map(function(field){ - // return '<li>' + field + '</li>' - // }); - // xmodal.message({ - // title: 'Validation Failed', - // content: '' + - // '<p>Please correct errors with the following fields:</p> ' + - // '<ul>' + errors.join('') + '</ul>' - // }); - // return false; + // VALIDATION ERRORS WILL STOP FORM SUBMISSION + errors = errors.map(function(field){ + return '<li>' + field + '</li>' + }); + xmodal.message({ + title: 'Validation Failed', + content: '' + + '<p>Please correct errors with the following fields:</p> ' + + '<ul>' + errors.join('') + '</ul>' + }); + return false; } var inputs = $inputs.toArray(); @@ -636,7 +637,7 @@ var XNAT = getObject(XNAT||{}), $.fn.submitJSON = function(opts){ var $form = $(this); $form.addClass('json'); - return xhr.form(this, extend(true, { + return xhr.form($form, extend(true, { method: $form.data('method') || this.method || 'POST', processData: false, contentType: 'application/json' -- GitLab