From 0f4de69e57874e333d500075ff5395020e3198b7 Mon Sep 17 00:00:00 2001 From: Hideki Saito Date: Mon, 19 Aug 2019 09:15:29 +0000 Subject: [PATCH] Fixed form validation to JT survey minimum & maximum values - Fixed issue ansible/tower#3679 Signed-off-by: Hideki Saito --- .../survey-maker/surveys/init.factory.js | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/awx/ui/client/src/templates/survey-maker/surveys/init.factory.js b/awx/ui/client/src/templates/survey-maker/surveys/init.factory.js index 19319c4ce9..d47be4a5c0 100644 --- a/awx/ui/client/src/templates/survey-maker/surveys/init.factory.js +++ b/awx/ui/client/src/templates/survey-maker/surveys/init.factory.js @@ -262,33 +262,45 @@ export default if(scope.type.type==="text"){ if(scope.default && scope.default.trim() !== ""){ - if(scope.default.trim().length < scope.text_min && scope.text_min !== "" ){ - scope.minTextError = true; + if(scope.default.trim().length < scope.text_min && + scope.text_min !== "" && + scope.text_min !== null ){ + scope.minTextError = true; } - if(scope.text_max < scope.default.trim().length && scope.text_max !== "" ){ - scope.maxTextError = true; + if(scope.text_max < scope.default.trim().length && + scope.text_max !== "" && + scope.text_max !== null ){ + scope.maxTextError = true; } } } if(scope.type.type==="textarea"){ if(scope.default_textarea && scope.default_textarea.trim() !== ""){ - if(scope.default_textarea.trim().length < scope.textarea_min && scope.textarea_min !== "" ){ - scope.minTextError = true; + if(scope.default_textarea.trim().length < scope.textarea_min && + scope.textarea_min !== "" && + scope.textarea_min !== null ){ + scope.minTextError = true; } - if(scope.textarea_max < scope.default_textarea.trim().length && scope.textarea_max !== "" ){ - scope.maxTextError = true; + if(scope.textarea_max < scope.default_textarea.trim().length && + scope.textarea_max !== "" && + scope.textarea_max !== null ){ + scope.maxTextError = true; } } } if(scope.type.type==="password"){ if(scope.default_password && scope.default_password.trim() !== ""){ - if(scope.default_password.trim().length < scope.password_min && scope.password_min !== "" ){ - scope.minTextError = true; + if(scope.default_password.trim().length < scope.password_min && + scope.password_min !== "" && + scope.password_min !== null ){ + scope.minTextError = true; } - if(scope.password_max < scope.default_password.trim().length && scope.password_max !== "" ){ - scope.maxTextError = true; + if(scope.password_max < scope.default_password.trim().length && + scope.password_max !== "" && + scope.password_max !== null ){ + scope.maxTextError = true; } } }