Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /////EditEmail.vue
- async addNewItem() {
- this.errors = [];
- if (this.newItem === "") {
- return;
- } else if (this.altEmail.length > 3) { //Uses n-1 size for some reason??
- this.errors.push("Too many emails, max 5");
- } else if (await this.api.validateEmail(this.newItem)) {
- this.errors.push("Email is not valid");
- } else {
- this.altEmail.push(this.newItem);
- this.newItem = "";
- }
- },
- /////Api.vue
- async validateEmail(email) {
- if (/^\w+([-]?\w+)*@\w+([-]?\w+)*(\.\w{2,3})+$/.test(email))
- {
- return true;
- } else {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement