Skip to content

Commit

Permalink
regex remail
Browse files Browse the repository at this point in the history
  • Loading branch information
DoublEffe committed Apr 11, 2024
1 parent d7568b4 commit dbe3f53
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions assets/JS/email-sender.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,24 @@ document.addEventListener('DOMContentLoaded',() =>{
name.value = ''
body.value = ''
}
const template_params = {'from_name': name.ariaValueMax, 'message': body.value}
form.addEventListener('submit', (event) => {
event.preventDefault()
emailjs.sendForm('service_gxjtpqf', 'template_faf6qip', form)
.then(() => {
clear()
console.log('SUCCESS!');
}, (error) => {
console.log(email.value.match(/^(\w)+@(\D)+\.\D{2,3}$/g))
if (email.value.match(/^(\w)+@(\D)+\.\D{2,3}$/g) && name.value.match(/\D/g) ) {
console.log('pp')
emailjs.sendForm('service_gxjtpqf', 'template_faf6qip', form)
.then(() => {
clear()
console.log('FAILED...', error);
});
window.alert('Message sended')
}, (error) => {
clear()
console.log(error)
window.alert('Error occurred')
});
}
else{
window.alert('incorrect email')
clear()
}
})
})

0 comments on commit dbe3f53

Please sign in to comment.