email validation

Results 1 to 2 of 2

Thread: email validation

  1. #1
    anamika Guest

    Default email validation

    Hi Friends!<BR><BR>I found some email validation in the net.<BR>could anyone please help me in sorting out the explantion of the synatx used here<BR>Code is :<BR> var filter=/^.+@.+..{2,3}$/<BR> if (!filter.test(str)) // where str is some value is passed for validation<BR> alert("Invalid email address!)<BR><BR>Thanx<BR>anamika(sukasaka@rediffm

  2. #2
    Dan Evans Guest

    Default RE: email validation

    The regular expression means:<BR>str must begin at least one non-newline character, followed by an @ followed by at least one non-newline character, followed by a dot(.), followed by at least 2 and at max 3 non-newline characters, then the string ends. Phew! I prefer this Reg Exp for email validation (although it&#039s not perfect) -<BR><BR>str = ""<BR>str.match(/^w+(.w+)*@w+(.w+)+$/)<BR><BR>It says:<BR>str must start with at least one word character (letters, numbers or underscore), followed optionally by a dot(.) and one or more word characters. This dot then word combo can be repeated any number of times. Then there is an @ followed by a word, followed by a dot and a word. This dot and word combo must exist at least once.<BR><BR>This Reg Exp doesn&#039t check the length of the last word (Usually 2 or 3 letters e.g., com, uk etc), but you could combine the two Reg Exp&#039s to get a more accurate result. Sorry this post was so confusing (I had to stop and reread the whole thing a couple of times). If you have any problems, email me (<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts