JavaScript Program to Check Whether Entered Email is Valid or not Using Regular Expression

Write a JavaScript program to check whether entered email is valid or not using Regular Expression.

Source Code
    <title>Check Email ID</title>
        function checkEmail()
            var email = document.getElementById('email').value
            var regex = /^([a-zA-Z0-9_\.]+)@([a-zA-Z0-9_\.]+)\.([a-zA-Z]{2,5})$/
            var res = regex.test(email)

                alert('Please enter valid email id')
                alert('Thank you')
<form name="myform" action="#" method="post">
    Enter Email ID <input type="text" id="email" /><br/>
    <input type="button" value="Submit" onclick="checkEmail()"/>

"Coding Hub - Learn to code" app now available on Google Play Store