javascript function to check if the email address is valid Edit

Murugan Andezuthu Dharmaratnam | 30 October 2020 | 42

Subtitle with Paragraph

Here is the sample script written using regex to check if the email is valid

Email valid script

function emailvalid(str) {
    var pattern = /^\w @[a-z0-9A-Z_] ?\.[a-z0-9A-Z]{2,3}$/;
    var match = str.match(pattern);
    if (match == null) {
        return false;
    } else {
        return true;
    }
}

call it by using the code below
var str = $("#email").val();
emailvalid(str)