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

HTML

Form Validation, Any hints, suggestions and comments are welcome thank you in advance for your help!!!

Programming the "Form Validation" section requires working with the following elements:

The "Name" <input type="text"> element (should already have a variable) The "Email Address" <input type="text"> element The "Register for Activities" <fieldset> element (should already have a variable) The "Card number" <input type="text"> element The "Zip code" <input type="text"> element The "CVV" <input type="text"> element The <form> element Create variables for the above elements that haven’t already had variables created for them, and log them out to ensure they are what you expect them to be. Use the "form" variable to listen for the submit event. Inside the event listener, use the name variable, dot notation and the value property to create a new variable that references the value of the “Name” field. Create another variable to store the results of testing the name value variable that was just created. Regex will be helpful, and the regex course from this unit will demonstrate how to do this. This variable will equal true if the test passes, and false otherwise. Log these variables out to the console to check the "Name" field’s value and if it passes the custom validation test. To see this log statement printed to the console, you’ll have to do three things: Enter something into the “Name” field Add a temporary event.preventDefault() statement to prevent the form from refreshing when the submit button is clicked. Click the submit button Still in the event listener, use the name validation test variable and an if statement to check if the name value is valid. If false, prevent the form from submitting with an event.preventDefault() statement. Otherwise, do nothing and allow the form to submit. Repeat steps 3 through 6 above for each of the required fields. Review the project instructions for the list of required fields or sections and the validation requirements of each. And remember that the credit card fields should only be validated if "credit card" is the selected payment method.