diff --git a/awx/ui/static/js/forms/SurveyQuestion.js b/awx/ui/static/js/forms/SurveyQuestion.js
index f429852fac..89c4a59dfb 100644
--- a/awx/ui/static/js/forms/SurveyQuestion.js
+++ b/awx/ui/static/js/forms/SurveyQuestion.js
@@ -62,7 +62,7 @@ angular.module('SurveyQuestionFormDefinition', [])
'data-placement="right" data-container="body" data-title="Answer Variable Name" class="help-link" data-original-title="" title="" tabindex="-1"> '+
'
'+
'
A value is required!
'+
- '
Please remove spaces
'+
+ '
The value contains an illegal character!
'+
'
'+
'
',
addRequired: true,
diff --git a/awx/ui/static/js/helpers/Survey.js b/awx/ui/static/js/helpers/Survey.js
index 17fabdf65e..0801ae512e 100644
--- a/awx/ui/static/js/helpers/Survey.js
+++ b/awx/ui/static/js/helpers/Survey.js
@@ -397,10 +397,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
scope.float_min = null;
scope.float_max = null;
-
-
-
-
if (scope.removeFillQuestionForm) {
scope.removeFillQuestionForm();
}
diff --git a/awx/ui/static/lib/ansible/directives.js b/awx/ui/static/lib/ansible/directives.js
index 8282a43944..1cef146fd8 100644
--- a/awx/ui/static/lib/ansible/directives.js
+++ b/awx/ui/static/lib/ansible/directives.js
@@ -239,16 +239,16 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
//the awSurveyVariableName directive checks if the field contains any spaces.
// this could be elaborated in the future for other things we want to check this field against
.directive('awSurveyVariableName', function() {
- // var FLOAT_REGEXP = /^\-?\d+((\.|\,)\d+)?$/;
+ var FLOAT_REGEXP = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
return {
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
ctrl.$parsers.unshift(function(viewValue) {
- if (viewValue.indexOf(' ') === -1) {
+ if (FLOAT_REGEXP.test(viewValue) && viewValue.indexOf(' ') === -1) { //check for a spaces
ctrl.$setValidity('variable', true);
return viewValue;
} else {
- ctrl.$setValidity('variable', false);
+ ctrl.$setValidity('variable', false); // spaces found, therefore throw error
return undefined;
}
});