Skip to content

Commit

Permalink
FIX: Prevent whitespace from being pasted into fields
Browse files Browse the repository at this point in the history
in the ConditionsWidget
  • Loading branch information
RevolutionTech committed Mar 9, 2018
1 parent ae3c98a commit 4a1f7da
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion conditions/static/conditions/js/conditions_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,15 @@ $(function(){
return this.condition_selector_parent_group.updateJSON();
}

// Prevent spaces from being entered in condition keys and operands
// Prevent spaces from being entered in or pasted into condition keys and operands
$('#condition-key > input, #condition-operand > input').on('keydown', function(e) {
return e.which !== 32;
}).bind('paste', function() {
var input_pasted_in = $(this);
setTimeout(function() {
var pasted_text_wo_whitespace = input_pasted_in.val().replace(/\s+/g, '');
input_pasted_in.val(pasted_text_wo_whitespace);
});
});

$('#condition-json > textarea').val(prettifyJSON(this.encodeJSON()));
Expand Down

0 comments on commit 4a1f7da

Please sign in to comment.