0

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....

PoliDev
  • 1,408
  • 9
  • 24
  • 45
  • check here may be you get any help [Email validation](http://stackoverflow.com/questions/2507030/email-validation-using-jquery) – Himanshu Mar 22 '14 at 10:07

3 Answers3

2

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

BlackPearl
  • 2,532
  • 3
  • 33
  • 49
1

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.

Sunil Devre
  • 374
  • 1
  • 15
-1

User this regular expression this will help you.

/^([a-zA-Z0-9_\.\-])+\@((a-zA-Z0-9-]+\.)+([a-zA-Z0-9][2,4])+$/;

5Star
  • 61
  • 7