jQuery Validation

March 10th, 2020
jquery

Manipulating the DOM

I've been given the the task at work of fixing up some validation from a form that's found all over the website. It's on almost every single article in the website and the validation is flawed. Right now, if you wanted to put all 0's down for your phone number, there's nothing stopping you from doing so. The email field has poor validation as well. In React, I would just hook up one of the many packages devoted to form validation and get on with my day. It probably wouldn't take more than a day to figure out. This, however, is written in jQuery. I've spent maybe a few hours out of the many hundreds of my study time looking at jQuery and never really got that deep into it, but in the last 2 days, I've learned more about it than I ever cared to know. Initially, my plan was to scrap the jQuery and go with a validation package built specifically for JavaScript, but I really had a hard time finding one that did exactly what I wanted it to do. I found one that worked with jQuery, and spent the better part of half my day messing around with this package. Eventually, though, I figured out enough about jQuery and the code I was working with to ditch the package and build it out myself. I was going to move away from jQuery completely, but I decided to stay with it in the end, and use some of the code that had already been written. I just cleaned it up a bunch.

clean up

I'm nowhere near done, but I'm a lot further along than I was when the day started. Halfway through the day, I started to feel like I had actually made the codebase worse than when I started, and that it performed better than when I started, which was probably true at that point. But, when I decided to ditch the package and start figuring things out on my own, eventually things started to work. I was dealing with an event listener for a solid hour or so before I stepped away from the computer. I took my fifteen minute break, thought things through, and when I came back, I got things working. First, I got the phone number working with some regex and couple of conditionals, and then I moved on to the email address. At one point, I had about 20 tabs open from Stack Overflow and MDN, but I found my way. Learning at home watching tutorials and building projects is a great way to learn, for sure, but working on enterprise code with a deadline and a purpose beats everything. I learned more today than I have in a long time, and it's only going to go exponential from here. If I can ever get past this project, I can start working on the plethora of React and React Native projects with the guy next to me, and my learning curve is going to skyrocket.

learning curve

I'm still doing my learning at home, but I won't need to spend hours studying anymore to get the same or more benefit than I did. Everything I'm doing at home is to benefit my work, so I can get a little bit further ahead. I have a lot of motivation to stay on top or ahead of things. The people I'm surrounded by are way better than me, and I don't want to end up looking like too much of an idiot; in fact, I want to be as helpful to the team as possible. I think they understand I'm pretty green and need a lot of training to get me where I need to be, but they don't seem to have a lot of time to do that. Once I'm working on the same projects as them, things might be a little different, but right now, it seems like everyone is working on their own project and there's very little collaboration. Everybody on the team has a different skillset, though, and they are all working on different facets of the codebase. The guy next to me, though, has pretty much the same skillset as I do; he's just more advanced than I am. So, when we really get going, I would hope that he would be able to bring me along in the areas I'm weak in so I can be more effective to the team. I don't want to slow him down, but if he wants me to be useful, he's going to have to give me some of his time. If I can get some mentoring from him, I'm going to become really effective in the areas I want to be effective in, like React, React Native, and even state machines, which are becoming the next big thing. He's building a project right now using XState, and I really can't wait to get to the point where he can start teaching me that stuff. As far as his React code, he's using hooks heavily and his code is very sophisticated, so I'm going to be learning from the top echelon.

Until tomorrow!

Created by Sam Thoyre, © 2019