# Prevent or delete CR from user input (carriage return)

**URL:** https://community.glideapps.com/t/prevent-or-delete-cr-from-user-input-carriage-return/86679
**Category:** Ask for Help
**Created:** [March 17, 2026, 2:28pm UTC](https://community.glideapps.com/t/prevent-or-delete-cr-from-user-input-carriage-return/86679 "2026-03-17T14:28:10Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)
#### Post date: [March 17, 2026, 2:28pm UTC](https://community.glideapps.com/t/prevent-or-delete-cr-from-user-input-carriage-return/86679/1 "2026-03-17T14:28:10Z")

</div>

What is the best way to handle this?

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [March 18, 2026, 12:18am UTC](https://community.glideapps.com/t/prevent-or-delete-cr-from-user-input-carriage-return/86679/2 "2026-03-18T00:18:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)
#### Post date: [March 22, 2026, 12:03am UTC](https://community.glideapps.com/t/prevent-or-delete-cr-from-user-input-carriage-return/86679/3 "2026-03-22T00:03:04Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Himaladin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/himaladin/32/71023_2.png) [@Himaladin](https://community.glideapps.com/u/Himaladin)
#### Post date: [March 22, 2026, 4:23am UTC](https://community.glideapps.com/t/prevent-or-delete-cr-from-user-input-carriage-return/86679/4 "2026-03-22T04:23:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)
#### Post date: [March 22, 2026, 8:06am UTC](https://community.glideapps.com/t/prevent-or-delete-cr-from-user-input-carriage-return/86679/5 "2026-03-22T08:06:15Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)
#### Post date: [March 29, 2026, 9:19pm UTC](https://community.glideapps.com/t/prevent-or-delete-cr-from-user-input-carriage-return/86679/9 "2026-03-29T21:19:49Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
