Restrict special characters and spaces from input

There seems to be a couple of threads in the forum related to the subject but both seem rather old and I’m enquiring if anybody might have a more updated view. This relates to restricting characters on a text “input” which would exclude special characters and spaces.

I can use filtering or regex and even conditions but from a UX perspective I was hoping to find a way to restrict the user entering those characters.

1 Like

I use regex when processing the input via a workflow. It’s probably the most common way to go about it. You could create a JS bridge using the Toolbox plugin to listen for specific key combinations (shift+2, etc.) and trigger a popup/alert.

Thank you for the reply @supernaturally, have gone down the route of triggering alerts should the given special character of space be used with regex but was hoping to see if there was away of excluding these being entered in the 1st place… Thank you for confirming your approach

Hey @Bubbleboy and @supernaturally (thanks for the link mention),

Here is a solution:

Ensure your bubble input field has a unique id. You can use javascript to achieve this (needs to load after elements are loaded/pageloaded). Make sure the bubble input field’s placeholder has a unique value you can use to recognize the element from javascript. You can later inject a new placeholder on this element after assigning it an id.

//assign field a unique id via placeholder recognition. 
$('input[placeholder="x042inputfield"]').attr('id', 'someuniqueid93');

document.getElementById("someuniqueid93").onkeypress = function(e) {
    var chr = String.fromCharCode(e.which);
    if (" aceg".indexOf(chr) >= 0)
        return false;

As you may notice the ignored characters will be the ones inside the quotes “aceg-”, thus ignoring characters a,c,e,g,-
You could probably do it in a better way, but this was just tested to work.

Good luck.


@gurun exemplary thanks very much

This topic was automatically closed after 70 days. New replies are no longer allowed.