r/javascript • u/Stegosource • Nov 21 '21
Building Super Powered HTML Forms with JavaScript
https://austingil.com/building-super-powered-html-forms-with-javascript/[removed] β view removed post
6
u/nnmrts Nov 21 '21
Nice video. I'm not someone who needs it, but why don't you guys just put the transcript into the video subtitles? Or at least format it a bit? This way it just looks like a very long string of unstructured text, and the timestamps don't really help either.
1
u/Stegosource Nov 22 '21
Good question. I wanted to share the video, but also wanted to provide a text alternative. It's hosted on YouTube which has it's own transcripts, but I wanted something on my website. At first, I just copied over the transcripts from YouTube. They needed a LOT of work.
So then I tried out a service that looked much better. I wasn't sure if I wanted to include the time stamps or not. Too many felt annoying, but I thought a few would be good as milestones.
It's my first foray into transcripts, so maybe you have some suggestions?
2
u/nnmrts Nov 22 '21
Well just split the text up a bit into some paragraphs and maybe add headlines. Some pictures could also help, especially when the transcript contains stuff like: "Here are a couple examples of some totally custom looking UI form components"
1
u/Jonatollah Nov 22 '21
You could just make an article and include examples and code snippets etc. Which would be more useful than a video to somebody actually trying to practice what you're teaching.
1
u/maddy_0120 Nov 22 '21
Very helpful. Thanks π
1
u/Stegosource Nov 22 '21
Of course. I want to follow up with a blog post as well. There's a couple things I want to go deeper on.
2
u/maddy_0120 Nov 22 '21
I would love to learn more. Thanks.
Also, I have a question about form submission.
I made a form in React for one of my projects a while ago. Initially I had all the inputs inside a form field, but I later changed it to a div because the form fields would reset on enter. I tried event.preventDefault but it did not work.
1
u/Stegosource Nov 22 '21
Sure thing. Well the article may be a while before it gets published. Best way to know when it comes out is to subscribe to my newsletter (https://austingil.com/newsletter/). I'll also post an update on Twitter a bit later on (https://twitter.com/Stegosource)
Regarding your example, I think the best thing to do when I run into scenarios like this is to build a basic example to assert my assumptions. To save you some time, I've built a demo with 3 examples. The last one sends the form data with fetch and may be what you're looking for. https://stackblitz.com/edit/react-ts-6ugqow?file=index.tsx
Other options, since you're using React is to use data binding to hold on to a copy of the input value in memory.
But the real question I have is whether you should be saving the input value after the submission in the first place. Start there and be sure that it's the best behavior for the user. Because it's not the browser's default behavior, which may be confusing. They may think the form data did not get sent properly. Especially if there is a long delay for the response.
2
u/maddy_0120 Nov 23 '21
Thanks for taking the time to help me out. I might have to rethink the way I do forms from now on. The old way was a bit janky.
2
u/Stegosource Nov 23 '21
Happy to help. If you want to do some more reading, I did a pretty in depth article series last year on it.
https://austingil.com/how-to-build-html-forms-right-semantics/
Planning to turn it into a book soon which will have a bit more, but mostly be the same content.
β’
u/Ustice Nov 22 '21
Thanks for your contribution! Weβre a large community, and in order to keep things organized and easier to find, we keep this subreddit mostly focused on professional-level Javascript posts. Your post would be more useful to newer members of our community, and therefore it should be posted to /r/LearnJavascript instead.