How to validate Email address in php in javascript?

In this tutorial learn how to validate email address in javascript, Validate Email address  in javascript, email validation using Example of valid email id


yoursite@gmail.com
your.site@donate.org
yoursite@you.net

use regular express  /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

in javascript



 Create a index.html




<form action="" method="post" accept-charset="utf-8">
<input type="hidden" name="username" value="Jack">
<input type="hidden" name="member_id" value="123">
<input type="text" name="name" value="" id="name" placeholder="Enter Name" class="hiddenname">
<br> <br><input type="text" name="email" value="" id="email" placeholder="Enter Email" class="hiddenemail" onblur="validateEmail(this);">
<br><br><input type="text" name="address" value="" id="address" placeholder="Enter address" class="address">
<br><br><input type="text" name="contact" value="" id="contact" placeholder="contact" onclick="some_function()">
<br><br><input type="submit" name="btnSubmit" value="Submit">
</form>


<script type="text/javascript">

function validateEmail(emailField){
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

        if (reg.test(emailField.value) == false) 
        {
            alert('Email Address is Invalid');
            return false;
        }

        return true;
}
</script>







No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...