Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript DOM Scripting By Example Adding and Removing Names Registering Names

Travis Williams
Travis Williams
2,886 Points

Error in console "A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters,..."

I am using Firefox 134.0 on Debian 12. I created the form and input variables and added the event listener on the submit event on the form and set it to log out the input value to the console. Here is my workspace snapshot, https://w.trhou.se/qqxb9erh61

When I save everything and preview in the browser, I get this error in the console.

A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element. port-80-kb5bywth86.ecs-production.treehouse-app.net

I found this post on stackoverflow, https://stackoverflow.com/questions/14196687/a-form-was-submitted-in-the-windows-1252-encoding and added the accept-charset=utf-8 to the form element and it resolved the error, but I didn't see my input value logged out.

I continued watching the video and added the preventDefault() method and now I see my input logged to the console.

I went back and undid my changes to the form element and the code is working now without the accept-charset=utf-8 attribute in the form element.

I'm not sure why preventDefault() has this affect in this browser, but I wanted to bring it up in case other users report the same issue.

I can bring this up in a support ticket too if that would be useful.

1 Answer

Travis Alstrand
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Travis Alstrand
Treehouse Project Reviewer

Hey there Travis Williams ! 👋

The initial error about Windows-1252 encoding is a warning from Firefox about potential character encoding issues. Adding accept-charset="utf-8" to the form element is indeed a correct way to resolve this warning but it should have been submitting as normal.

The reason you likely weren't seeing your input logged initially is because preventDefault() wasn't in place yet and the default behavior for form submissions is to send the data and refresh the page. Upon refreshing, the console log was likely removed before you could see it.

If you do experience further issues though, please continue to let us know here. Your post was laid out very nicely and informative, thank you!! I'll pass on the message about the warning you got and we'll see about adding some Teacher's Notes below the video so that others that may see don't go through the process you went through. 👍