Reputation: 1468
I want to make email field without allowing spaces. I alread gave reg like the following
@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$
Here how to add without spaces.. Help Me....
Upvotes: 0
Views: 105
Reputation: 61
User this regular expression this will help you.
/^([a-zA-Z0-9_\.\-])+\@((a-zA-Z0-9-]+\.)+([a-zA-Z0-9][2,4])+$/;
Upvotes: -1
Reputation: 384
Try this.......
var regexp = /^[a-zA-Z0-9-_]+$/;
var check = "Sunil";
if (check.search(regexp) == -1)
{ alert('invalid'); }
else
{ alert('valid'); }
hope this will help you.
Upvotes: 1
Reputation: 2785
This will do it in Jquery;
var email=('#myemailfield').val();//email field
var email_exp= /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/;
if (!email.match(email_exp)){ return Alert('Please, enter a valid E-mail to continue');}
Hope it helps
Upvotes: 2