I am doing a regexp validation for email. works fine but it allows the user to add the @.xyz.com
, but it is meaning less. how can i insure that, the user should only add the alphabet
next to @
symbol?
in the pattern i have added [\w\.]
for the reason to add after @
is @some.xx.com
purpose. ( user can enter . after/inside alphabet )
$(function(){
$('#email').on('keyup', function(event){
var email = event.target.value;
var pattern = /^([a-zA-Z]{3,})+@[\w\.]+\.(com|org)$/
if(!email) return false;
console.log(pattern.test(email));
})
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="text" name="email" id="email" value="" />
any one help me?