Tuesday, 13 August 2013

Javascript email validation ..

For Javascript email validation

Put This in code
(Form onsubmit="return validateForm()") this should be the submit value for form and then this code

<input name="email" placeholder="Email" type="text" class="textField" id="email" value=""/>

Now javascript fuction

<script type="text/javascript">   
function validateForm()
var email = document.getElementById('email');
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
            alert('Please provide a valid email address');
            return false;
else {
  return true;     

No comments:

Post a Comment