-3

Possible Duplicate:
Using a regular expression to validate an email address

i am looking to have a reg ex for email validation which should support the following -

  • Uppercase and lowercase English letters (a–z, A–Z)
    • Digits 0 to 9
    • Characters !#$%&'*+-/=?^_`{|}~
    • Character . (dot, period, full stop) provided that it is not the first or last character, and provided also that it does not appear two or more times consecutively (e.g. abhi..shekk@example.com).
    • Special characters are allowed with restrictions including:
      • Space and "(),:;<>@[]

I need to validate the email ID using javascript method on form submission ?

Thanks,

Abhishek

Community
  • 1
  • 1
abhishek
  • 1
  • 1
  • Welcome to SO. Please read the FAQ before posting. We will gladly help with specific questions. It is not a place for giving us assignments and expecting them to be done in their entirety. Do some research, try something, then if it's not working out come back and we can help. – Mitya Jul 16 '12 at 11:56
  • 2
    Do some search. There are many of such question already. – nhahtdh Jul 16 '12 at 12:00

1 Answers1

1

First, I don't understand the last item of the list of requirements of Regular Expression:

  • Special characters are allowed with restrictions including:
    • Space and "(),:;<>@[]

The second, you should ALWAYS validate regular expression on server side. Because unless you are doing so, validating has no sense - client may use his own tool to send request to server. client validation will be good for warning user about mistakes prior to submission of the form. And yes, you should validate all fields on form submission. You could run any JavaScript function. <form> tag has event onSubmit() for that.

seeker
  • 3,255
  • 7
  • 36
  • 68
  • Special characters are allowed with restrictions including: Space and "(),:;<>@[] --- This means these special character are not allowed..!! – abhishek Jul 16 '12 at 13:43