Wednesday 28 March 2018

Javascript Validation Code to Block Free Emails (Gmail, Yahoo) & Allow Business Emails in Forms

Leejo.

<html>
<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<script type="text/javascript">

$(document).ready(function(e){

$('#btnSubmit').click(function(){ 

var email = $('#Email').val();

var reg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com)(?!yahoo.co.in)(?!aol.com)(?!abc.com)(?!xyz.com)(?!pqr.com)(?!rediffmail.com)(?!live.com)(?!outlook.com)(?!me.com)(?!msn.com)(?!ymail.com)([\w-]+\.)+[\w-]{2,4})?$/;

if (reg.test(email)){

return 0;

}

else{

alert('Please Enter Business Email Address');

return false;

}

});

});

</script>

</head>

<body>

<form id="yourid" action="" method="POST/GET">

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

<input type="submit" id="btnSubmit" name="download_submit" value="Submit">

</form>

</body>

</html>

No comments:

Post a Comment