The BEST way to do form validation in JavaScript

  Рет қаралды 19,971

Code With Bubb

Code With Bubb

Күн бұрын

Пікірлер: 57
@codewithbubb
@codewithbubb 2 жыл бұрын
Do you ever create your own form validation in JavaScript now? Or are you using some package/library with your React/Angular/Vue projects?
@celfabri-n7h
@celfabri-n7h 8 ай бұрын
I came here for the validation but I am so glad that I watched you put that form together as well. Great stuff.
@codewithbubb
@codewithbubb 8 ай бұрын
Cheers! Hope you found it useful.
@astroboy3720
@astroboy3720 2 жыл бұрын
KZbin need more stuff like that, every channel has the same extra-beginner stuff, thank you 🙏🙏⭐⭐
@codewithbubb
@codewithbubb 2 жыл бұрын
Cheers! Yeah, I did some polls in the community tab here a few months ago and people are asking for more advanced stuff so glad you found it useful!
@okolipeace774
@okolipeace774 6 ай бұрын
This is such a great video, and so easy to understand. So glad i found it, it really helped clear some questions i had about form validation. Thank you
@codewithbubb
@codewithbubb 6 ай бұрын
Thanks very much! Glad you found this useful! Appreciate your support.
@Christy-Bee
@Christy-Bee 8 ай бұрын
Thanks Bubb for this video, which goes way further in code structuration then most I have seen on this topic. I just wonder why you chose to add the icon elements in the HTML instead of creating / removing them in the JS script. Would you proceed that way in real life or is it only for the video purposes?
@codewithbubb
@codewithbubb 8 ай бұрын
Thanks very much. With regards to the icons - can't remember what my thoughts were with this originally! I guess it depends on how you were going to make use of this validation script in other projects - if you wanted it to be flexible I would probably put the icons in the markup and then get the script to show/hide them which means you can replace them with whatever icons you wish (and adjust layout etc with each project). Adding/removing them from the script offers more out-of-the box functionality if you wanted to reuse the script as you wouldn't have to provide icons etc just plug the validation script in and it works without any further requirements. So different scenarios depending on how you wanted to use the script in different projects I guess.
@MonotonyTV
@MonotonyTV 2 жыл бұрын
Good to see you were on my KZbin Home Page today - 27.05.2022 08:07
@codewithbubb
@codewithbubb 2 жыл бұрын
Glad you dropped by for a watch 😉
@LagrangePoint0
@LagrangePoint0 3 ай бұрын
Awesome tutorial!
@mabillama
@mabillama Жыл бұрын
Great thinking and logic implementation. A masterclass
@nehakannaujia9165
@nehakannaujia9165 11 ай бұрын
Really nice video thanks for sharing , wish I had seen it before. We need more stuff like this which is for advance levels. Good job
@codewithbubb
@codewithbubb 11 ай бұрын
Thank you very much! Glad you found it useful.
@nehakannaujia9165
@nehakannaujia9165 11 ай бұрын
@@codewithbubb I would love see more advance level video on react as I m just finishing basic level and still not very confident how we usually work in actual projects in job. If you could please make more videos on react similar to this one please that would be awesome :-)
@codewithbubb
@codewithbubb 11 ай бұрын
Well, i'm not sure what you mean by 'advanced' but I have quite a few React projects on the channel at the moment: kzbin.info/aero/PLpc_YvcwbxaTqVUVgWQhISClv_mniIm2o but i'll probably be doing some more stuff in the future so watch out for that 😉
@nehakannaujia9165
@nehakannaujia9165 11 ай бұрын
@@codewithbubb by advanced i meant how we use in actual projects that is reusable and better structured like this form validation. I have seen lots of react tutorial on state, use effects and they just show the basic stuff for a simple method. Would like to see more how we use it in real complex applications. Perfect thanks i will check those out
@falanlaguerre3799
@falanlaguerre3799 Жыл бұрын
Thank you for the great video, should this work for 'select' tags as well?
@ryanwalter9373
@ryanwalter9373 Ай бұрын
I really want to understand how the minLength attribute property had more precedence over the required attribute property
@joeljefferson1310
@joeljefferson1310 Жыл бұрын
Thanks, It was very helpful!
@codewithbubb
@codewithbubb Жыл бұрын
Great! Glad you found it useful.
@relja_
@relja_ Жыл бұрын
Really nice video, very different from other validation vids out there. I have a question. What's the difference between your method and using checkValidity() method from JS api?
@johnoppong876
@johnoppong876 2 жыл бұрын
Very helpful
@codewithbubb
@codewithbubb 2 жыл бұрын
Thanks John!
@inteltone
@inteltone Жыл бұрын
If you use event.preventDefault() in your validation function, you need to manually submit the form if it is valid. Am I right? For example, if(valid) { formElement.submit() }
@codewithbubb
@codewithbubb Жыл бұрын
Yeah absolutely right! If you preventDefault on a form submit the action of the form is stopped so to continue you it you can submit the form manually or (more probable) send the data from the form off to an API endpoint for submission e.g. via Fetch.
@_r4in.1
@_r4in.1 5 ай бұрын
hey! idk why i'm not getting the errors and no texts appear.. idk why is that, but can you give me the source-code so i can see what im doing wrong.. ?
@codewithbubb
@codewithbubb 5 ай бұрын
Sorry to hear you're having problems. Here's the code for the tutorial: github.com/codebubb/javascript-form-validation-tutorial
@takisnani5337
@takisnani5337 2 жыл бұрын
Hi, Thanks for the tutorial! I'm wondering if someone edit our html with the inspect element? it will work? Thanks again!
@jaylonnichols5504
@jaylonnichols5504 Жыл бұрын
Great video but it there is a problem. The error message will not go away until I have clicked the submit button twice and then it will go away. Does anyone know why this is?
@j4ck3
@j4ck3 Жыл бұрын
nice work man
@sidarjunful
@sidarjunful 2 жыл бұрын
Excellent
@codewithbubb
@codewithbubb 2 жыл бұрын
Thanks very much Siddharth!
@marie484
@marie484 Жыл бұрын
Hello. A great code for validation. I've tried doing it on my own form and it worked fine when the form was placed in the html code, but when I rewrote the code and loaded the form dynamically the validation no longer worked. Getting error here: formElement.setAttribute('novalidate', ' ' ); Uncaught TypeError: Cannot read properties of null (reading 'setAttribute') at validateForm (main.js:376:17) i.e. now only the html validation works. What can I do to make the javaScript validation work instead?? 🙂
@anitaabdurrahmani8354
@anitaabdurrahmani8354 Жыл бұрын
Hi, where can I find the code of your tutorial, because I don't wanna spend time on html/css part.. Thank you!
@codewithbubb
@codewithbubb Жыл бұрын
Hi Anita, it’s all on GitHub: github.com/codebubb/javascript-form-validation-tutorial
@romanryabchinskiy5521
@romanryabchinskiy5521 Жыл бұрын
Thank you for good lesson. But I encountered problem. Submit doesn't work (page doesn't reload after filling form and pressing submit button. Please could you help me with this issue! Thank you in advdnce!
@inteltone
@inteltone Жыл бұрын
If you use event.preventDefault() in your validation function, you need to manually submit the form if it is valid. For example, if(valid) { formElement.submit() }
@zuekiin
@zuekiin 8 ай бұрын
After the first validationOptions for the required attribute my form only display error for only the first input field. Does anybody else have the same issue?
@Christy-Bee
@Christy-Bee 8 ай бұрын
Yep! I encountered same issue and checked my HTML file. I had a typo in error-icon which I initally entered with 1 r (eror). You probably have the same type of issue. Check the spelling!
@codewithbubb
@codewithbubb 8 ай бұрын
Hi, yeah would probably need to take a look at your code if you're still having problems if you can share it at all. Like @Christy-bee says - check for typos!
@codewithbubb
@codewithbubb 8 ай бұрын
Thanks for helping out!
@nenadbanjeglav2081
@nenadbanjeglav2081 Жыл бұрын
This is sooo good! Thanks a lot!
@codewithbubb
@codewithbubb Жыл бұрын
Thanks very much!
@lukas.szarkowski
@lukas.szarkowski 2 жыл бұрын
Would you post the code for this tutorial? :)
@codewithbubb
@codewithbubb 2 жыл бұрын
Yep sure, I’ll share the GitHub repository with you when I get a chance.
@lukas.szarkowski
@lukas.szarkowski 2 жыл бұрын
@@codewithbubb Great! I can't wait! :D
@codewithbubb
@codewithbubb 2 жыл бұрын
Here's the code Lukas: github.com/codebubb/javascript-form-validation-tutorial It's probably worth saying you might want to return true/false for the overall validation function if you were going to apply this to a form you were using. Hope that helps!
@lukas.szarkowski
@lukas.szarkowski 2 жыл бұрын
@@codewithbubb Thanks a lot! I am just learning the forms and you fell out of the sky for me! I will study it calmly and it will be useful in the future.
@codewithbubb
@codewithbubb 2 жыл бұрын
Ok no problems! Let me know if you have any questions!
@saipavankumar4498
@saipavankumar4498 2 жыл бұрын
Hi sir Can u provide the source code
@codewithbubb
@codewithbubb 2 жыл бұрын
Hi, it's on GitHub the JS code can be found here: github.com/codebubb/javascript-form-validation-tutorial/blob/main/script.js
@muhammadIbrahim-vd9fm
@muhammadIbrahim-vd9fm 2 ай бұрын
sourc code plase
@DeveshKumar-hs4qo
@DeveshKumar-hs4qo 2 жыл бұрын
i spent two days on your project but i didn't get your logics in JavaScript you were just writing code without explaining it properly, you really demotivated bro🥲🥲
@codewithbubb
@codewithbubb 2 жыл бұрын
So sorry to hear that Devesh. There was a lot to go through in this tutorial and I wanted to keep a good pace so it didn’t turn into a lengthy, dull tutorial. If there’s any thing I can elaborate, please don’t hesitate to ask and I’ll do my best to explain 😂
10 Form Validation Tips Every Web Developer SHOULD KNOW!
9:22
James Q Quick
Рет қаралды 16 М.
ROSÉ & Bruno Mars - APT. (Official Music Video)
02:54
ROSÉ
Рет қаралды 274 МЛН
The Singing Challenge #joker #Harriet Quinn
00:35
佐助与鸣人
Рет қаралды 10 МЛН
Yay, My Dad Is a Vending Machine! 🛍️😆 #funny #prank #comedy
00:17
Mastering ZOD for validation in Nextjs
41:14
Chai aur Code
Рет қаралды 72 М.
JAVASCRIPT FORM VALIDATION AND SUBMIT TO ANOTHER PAGE
1:01:34
CODE LAB
Рет қаралды 65 М.
Form Validation Part II - JS and the Constraint Validation API
32:19
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 6 М.
Learn JavaScript With This ONE Project!
1:10:26
Tech With Tim
Рет қаралды 750 М.
How to Create a Custom Form Validator with JavaScript
25:13
Improve your form validation hints without JS!
12:46
Kevin Powell
Рет қаралды 67 М.
JavaScript Form Validation For Beginners
16:37
Web Tech Knowledge
Рет қаралды 32 М.
JavaScript Visualized - Event Loop, Web APIs, (Micro)task Queue
12:35