s

javascript function to check if the email address is valid edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 30 October 2020 | 1599

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)