diff --git a/api/tests/test.js b/api/tests/test.js index e69de29..28ea815 100644 --- a/api/tests/test.js +++ b/api/tests/test.js @@ -0,0 +1,7 @@ +function ValidateEmail(mail) { + if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(myForm.emailAddr.value)) { + return (true) + } + alert("You have entered an invalid email address!") + return (false) +} \ No newline at end of file diff --git a/api/utils/mail_validator.js b/api/utils/mail_validator.js index e69de29..df24ca8 100644 --- a/api/utils/mail_validator.js +++ b/api/utils/mail_validator.js @@ -0,0 +1,12 @@ +function ValidateEmail(email) { + var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/; + if (email.value.match(mailformat)) { + //change the input tag to focus + document.form.text.focus(); + return true; + } else { + alert("You have entered an invalid email address!"); + document.form.text.focus(); + return false; + } +} \ No newline at end of file