var content = 'MY TEXT WITH INVISIBLE CHARS'; if (content.search(/[^\u0000-\u007E]/g) >= -1) { content.replace(/[^\u0000-\u007E]/g, ""); this.code.set(content); }