Best Jquery ,javascript, HTML5 CSS3 tutorial with jquery examples, php script , demos for beginners, web designers and web developers.

Jquery

Jquery Training

Jquery training blog

Email validation

<html> <head> <title>Email validation </title> <script src=”https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js”></script> </head> <body> HTML 5 validation <form name=”html5valid” method=”post” action=”#”> <input type=”email” name=”email”/> <input type=”submit” name=”submit”/> </form> Pure Javascript and jquery onclick validation</br> <input type=”text” name=”email” id=”email”> <button type=’button’ id=’validate’>Javascript Validation</button> <button type=’button’ id=’jquery_validate’>Jquery Validation</button> <h2 id=’result’></h2> <script> function validateEmailAddress(email) { var re = /^(([^<>()\[\]\\.,;:\[email protected]”]+(\.[^<>()\[\]\\.,;:\[email protected]”]+)*)|(“.+”))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } function Continue Reading


<html>
<head>
<title>Email validation </title>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
</head>
<body>
HTML 5 validation
<form name="html5valid" method="post" action="#">
<input type="email" name="email"/>
<input type="submit" name="submit"/>
</form>

Pure Javascript and jquery onclick validation</br>

<input type="text" name="email" id="email">

<button type='button' id='validate'>Javascript Validation</button>

<button type='button' id='jquery_validate'>Jquery Validation</button>


<h2 id='result'></h2>



<script>
function validateEmailAddress(email) {
var re = /^(([^<>()\[\]\\.,;:\[email protected]"]+(\.[^<>()\[\]\\.,;:\[email protected]"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}

function validateEmail() {
document.getElementById('result').innerHTML="";
var email = document.getElementById('email').value;
if (validateEmailAddress(email)) {
document.getElementById('result').innerHTML=email + " is valid ";
document.getElementById('result').style.color="green";
} else {
document.getElementById('result').innerHTML=email + " is not valid ";
document.getElementById('result').style.color="red";
}
return false;
}

document.getElementById('validate').addEventListener('click', function() {
validateEmail();

});

function validate() {
$("#result").text("");
var email = $("#email").val();
if (validateEmailAddress(email)) {
$("#result").text(email + " is valid ");
$("#result").css("color", "green");
} else {
$("#result").text(email + " is not valid ");
$("#result").css("color", "red");
}
return false;
}
$("#jquery_validate").bind("click", validate);
</script>

 

</body>
</html>
Please follow and like us:






About the author

Joydeb Choudhury holds a Master's degree in Computer Application from I.G.N.O.U. After working as a web developer in various companies he has started bloging in 2016.

Recent Posts of blog

Downalod Free Php Scripts