Advertisement
Guest User

Untitled

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