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 trialRyan Magdaleno
6,447 PointsWhat would be the implications of forcing the correct input on the front end vs handling exceptions in the code?
Importance of learning exception handling aside, and more of a general conceptual question, but would this be considered bad/good practice? I'm imagining an app with an input field and a submit button that isn't clickable until the field's values match the criteria, or selected from a drop down etc.
1 Answer
Steven Parker
231,275 PointsWhat you are describing is known as "client-side validation", and is considered good practice. It also gives the user a much better interactive experience.
Best practice is to combine client-side and server-side validation. This gives the user the best experience, plus it confirms input validity after reception to guard against bugs or possible malicious misuse attempts using modified front-end code.
Ryan Magdaleno
6,447 PointsRyan Magdaleno
6,447 PointsThat makes sense, thanks for the reply!
Steven Parker
231,275 PointsSteven Parker
231,275 PointsRyan Magdaleno — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!