Prevent or delete CR from user input (carriage return)

What is the best way to handle this?

No native way to prevent it, you might be able to prompt your way to an entry like that using the Custom component though.

Or you can use a JavaScript function to clean the carriage returns from a string, something like.

return p1.replace(/[\r\n]+/g, '')

Which means replacing all carriage returns and line feed/newline (I assume you might not want those as well) with an empty string.

2 Likes

Thank you, I used REGEXREPLACE(B2:B;ā€œ/[\r\n]+/gā€;ā€œā€) as arrayformula in Google Sheets.

1 Like

It might be cleaner to handle this in a Glide JavaScript column instead of Google Sheets, since it avoids cross-platform dependency and keeps the logic closer to the app.

3 Likes

I am not familiar with Glide Javascript, would this be appropriate?

if (!p1) return ā€œā€; return p1.toString().replace(/\r|\n/g, ā€˜ā€™).trim();

The REGEX solution will clean up old line breaks, This will prevent new, thank you!

2 Likes

(post deleted by author)

We faced a similar challenge with role-based access in our Glide app. The cleanest pattern we found is using a Users table with a dedicated Role column, then adding visibility conditions on each screen/component that check the current user email against the Role field.

One thing to watch: if you use row owners alongside role-based visibility, there can be edge cases where row-owner filtering prevents the role lookup from finding the right record. In that case, it is cleaner to keep your Users table without row owners and handle data access permissions at the component level using visibility conditions instead.

(post deleted by author)