# WebTextField.TextChanged and Chr(13) to trigger submit

**URL:** <https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853>\
**Category:** Web\
**Created:** [March 6, 2021, 10:20pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853 "2021-03-06T22:20:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![William\_Reynolds](https://forum.xojo.com/user_avatar/forum.xojo.com/william_reynolds/32/565_2.png) [@William\_Reynolds](https://forum.xojo.com/u/William_Reynolds)\
**Post date:** [March 6, 2021, 10:20pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853/1 "2021-03-06T22:20:13Z")

</div>

For any field where a value is entered it’s common to accept the CR as an indication that the user is done entering data and wants to submit it. My WebTextField.TextChanged event works as expected on all characters except a Carriage Return. What am I overlooking?

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [March 6, 2021, 10:28pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853/2 "2021-03-06T22:28:44Z")

</div>

Are you setting the field’s value as the following and expecting something to happen:

```xojo
myField.Value = "something" + Chr(13)

```

Or do you mean that pressing the Enter key on your keyboard doesn’t trigger an action?

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [March 6, 2021, 10:31pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853/3 "2021-03-06T22:31:12Z")

</div>

The right way to do this currently is to have a button with the Default property set to True. When hitting the Enter key, the Button’s Pressed event will be triggered.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [March 6, 2021, 10:32pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853/4 "2021-03-06T22:32:24Z")

</div>

Return and ESC are captured at the page level and trigger the buttons that are designated as Default and Cancel respectively.

These in turn tell all TextFields and TextAreas to first send their latest data to the server if necessary before sending their Pressed event.

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [March 6, 2021, 10:33pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853/5 "2021-03-06T22:33:54Z")

</div>

You can even create WebContainers with their own Default and Cancel buttons that trap these events and don’t trigger the Pressed events of other Default and Cancel buttons on the same page.

---

<div class="post-metadata">

**Author:** ![William\_Reynolds](https://forum.xojo.com/user_avatar/forum.xojo.com/william_reynolds/32/565_2.png) [@William\_Reynolds](https://forum.xojo.com/u/William_Reynolds)\
**Post date:** [March 6, 2021, 10:39pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853/6 "2021-03-06T22:39:38Z")

</div>

It’s a combo of fields used for a login (in this instance). The UserID (email address) is on field, then a tab takes you to PWD field where user types in their password - then intuitively they’ll hit the CR/Enter key to ‘submit’ their login. It’s the CR/Enter value I’m hoping to detect.

---

<div class="post-metadata">

**Author:** ![Anthony\_G\_Cyphers](https://forum.xojo.com/user_avatar/forum.xojo.com/anthony_g_cyphers/32/16862_2.png) [@Anthony\_G\_Cyphers](https://forum.xojo.com/u/Anthony_G_Cyphers)\
**Post date:** [March 6, 2021, 10:51pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853/7 "2021-03-06T22:51:40Z")

</div>

Presumably you also have a “Login” button. If so, set its Default property to True in the Inspector and execute your login from its Pressed event. Then, when pressing Enter on one of the fields, this will execute.

---

<div class="post-metadata">

**Author:** ![William\_Reynolds](https://forum.xojo.com/user_avatar/forum.xojo.com/william_reynolds/32/565_2.png) [@William\_Reynolds](https://forum.xojo.com/u/William_Reynolds)\
**Post date:** [March 6, 2021, 10:54pm UTC](https://forum.xojo.com/t/webtextfield-textchanged-and-chr-13-to-trigger-submit/61853/8 "2021-03-06T22:54:51Z")

</div>

Yep - that works perfectly (‘Default’). I’ll follow the design guidelines as @Greg_O_Lone cited above. I will have other pages with more than one area container that accepts user input, so I’ll have to prototype having several ‘Default’ buttons in several containers and studying what that does.
