Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. validateEmail(email) {
  2. if (/^\w+([-]?\w+)*@\w+([-]?\w+)*(\.\w{2,3})+$/.test(email))
  3. {
  4. return true;
  5. } else {
  6. return false;
  7. }
  8. },
  9.  
  10. addNewItem() {
  11. this.errors = [];
  12. if (this.newItem === "") {
  13. return;
  14. } else if (this.altEmail.length > 3) { //Uses n-1 size for some reason??
  15. this.errors.push("Too many emails, max 5");
  16. } else if (!this.validateEmail(this.newItem)) {
  17. this.errors.push("Email is not valid");
  18.  
  19. } else {
  20. this.altEmail.push(this.newItem);
  21. this.newItem = "";
  22. }
  23.  
  24. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement