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

JavaScript

Joseph Escobedo
seal-mask
.a{fill-rule:evenodd;}techdegree
Joseph Escobedo
Full Stack JavaScript Techdegree Student 4,172 Points

I have the validator functions ready, but not sure how to implement them into another master validator

I'm towards the end of the Unit 3 project and I have my validator functions ready to go for each input, but now I'm not so sure how to implement them into a master validator function where its going to make sure each input has the right information in it. I'm looking back at some of the code used in the course videos for unit 3, but they way they do it is different from the way we have to do it in the project. I'm going to need some sort of submit or click or even change function on the submit button, but when I click the button it just bring up a 405 error. If someone can push me in the right direction, that would be very helpful.

Validation functions:

//Validation functions

function isValidName(name) {
  return /[^a-z]+$/.test(name);
}

function isValidEmail(email) {
  return /^[^@]+@[^@.]+\.[a-z]+$/i.test(email);
}

function isValidActivity() {
  return startingCost != 0;
}

function isValidCreditCard(cardNumber) {
  return /^(?:4[0-9]{12}(?:[0-9]{3})?|[25][1-7][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/.test(
    cardNumber
  );
}

function isValidZipCode(zip) {
  return /[^\d](\d{5})[^\d]/g.test(zip);
}

function isValidCvv(cvv) {
  return /^[0-9]{3,4}$/.test(cvv);
}

/*
  I have my functions, now i just have to put it together,
  I'm not so sure how I am going to do that or where to implement my validator functions
*/

//I get an error 405 and it wont submit.
$("#button").on("submit", e => {
  e.preventDefault();
});

github js file: https://github.com/joeEscob1023/interactiveForm/blob/master/js/app.js