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 trial
Johan Rönkkö
28,054 PointsWorking with AJAX and Express - form validation
Hi! How would i go about validating a login/register - form with ajax before the data is getting sent to the express server? The reason being is, my form is a modal from bootstrap. Upon submitting, the page reloads and the modal goes away. My idea is to add the has-danger class from bootstrap when required fields are left empty. So, if some error occur i don't want to leave the page and display the errors. If no error occurs i want to leave the page and the Express server will redirect.
Karolin Rafalski
11,368 PointsKarolin Rafalski
11,368 PointsIs there any reason you don't want to use HTML validations?
There is a required attribute which can be styled ... https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Data_form_validation