Introduction
Here is a javascript function to validate email id.
you need to add class "email" in text control.
Code
Here is a javascript function to validate email id.
you need to add class "email" in text control.
Code
- <script type="text/javascript">
- $(document).ready(function () {
- $(".email").change(function () {
- var inputvalues = $(this).val();
- var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
- if(!regex.test(inputvalues)){
- alert("invalid email id");
- return regex.test(inputvalues);
- }
- });
- });
- </script>
- Html input type text
- Email : <input type="text" class="email" >