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 trialIsrael Baptiste
Courses Plus Student 4,147 Pointscontact form
What is the best way to validate your contact form? Please help
3 Answers
James Barnett
39,199 PointsIt depends on what sorts of fields you want to validate, in general you can:
- Mix HTML5 input patterns with a JQuery fallback
- Combine that with server-side PHP
- Add in a healthy dose of regex
- Stir and served chilled.
See also: http://html5pattern.com/
Alex Hedley
16,381 PointsAs James says make sure you validate server sde, this is a must since JS can be turned off in the browser so you can't rely on that alone.
I've used the following jquery plugin which is good http://bassistance.de/jquery-plugins/jquery-plugin-validation/
HTML5 has brought some great new features, cool keyboard changes on smartphones etc
Randy Hoyt
Treehouse Guest TeacherHey Israel,
James has it right. We have some content online in the latest projects that discuss this. Andrew talks about jQuery validation here:
- jQuery: Form Validation and Manipulation
I talk about creating the form and doing basic server-side validation in PHP here ...
... and then how to handle some more advanced server-side validation and send the email here ...