Skip to main content

Email Validation Using HTML and Java Script

Here Some code writing for Email Validation. Please check 

This Code is Education purpose, Copy all the code and paste it in the Notepad then Save it with HTML extension.




<!DOCTYPE html>
<html>
<head>
<script>
function validateForm() {
    var x = document.forms["myForm"]["email"].value;
    var atpos = x.indexOf("@");
    var dotpos = x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
        alert("Not a valid e-mail address");
        return false;
    }
}
</script>
</head>

<body>

<form name="myForm" action="/action_page.php" onsubmit="return validateForm();" method="post">
Email: <input type="text" name="email">
<input type="submit" value="Submit">
</form>
</body>

</html>





Comments

Popular posts from this blog

Create DropDown Menu Using HTML,JavaScript and CSS

Here Simple code  Using for DropDown Button.  Copy all the code in NOTEPAD then Save it with   . . (dot)HTML extension .  Example : testmenu.html, projectmenu.html,  and Run it on your Browser. <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> .dropbtn {     background-color: #3498DB;     color: white;     padding: 16px;     font-size: 16px;     border: none;     cursor: pointer; } .dropbtn:hover, .dropbtn:focus {     background-color: #2980B9; } .dropdown {     position: relative;     display: inline-block; } .dropdown-content {     display: none;     position: absolute;     background-color: #f1f1f1;     min-width: 160px;     overflow: auto;     box-shadow: 0px 8px 16px 0px r...