programming-examples/js/Vre1/Check whether the pattern of an e-mail address matches a specific format.js

14 lines
320 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function valid_email(str)
{
var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if(mailformat.test(str))
{
console.log("Valid email address!");
}
else
{
console.log("You have entered an invalid email address!");
}
}
valid_email('me-info@example.com');