Helper function - sanitize user inputs - chat_ui.js