Email Validation

Results 1 to 3 of 3

Thread: Email Validation

  1. #1
    Join Date
    Dec 1969

    Default Email Validation

    I have done some email validation, however there is some error as if user just key in @. it will just submit. Can I prevent that and make sure there must be some letter before the @ sign eg. ( below are de code i have done:<BR><BR>if ( == "")<BR>{<BR> alert("Pls enter a value for the \"Email\" field.");<BR>;<BR> return (false);<BR>}<BR><BR>var checkEmail = "@.";<BR>var checkStr =;<BR>var EmailValid = false;<BR>var EmailAt = false;<BR>var EmailPeriod = false;<BR>for (i = 0; i &#060; checkStr.length; i++)<BR>{<BR> ch = checkStr.charAt(i);<BR> for (j = 0; j &#060; checkEmail.length; j++)<BR> {<BR> if (ch == checkEmail.charAt(j) && ch == "@")<BR> EmailAt = true;<BR> if (ch == checkEmail.charAt(j) && ch == ".")<BR> EmailPeriod = true;<BR> if (EmailAt && EmailPeriod)<BR> break;<BR> if (j == checkEmail.length)<BR> break;<BR> }<BR><BR> if (EmailAt && EmailPeriod)<BR> {<BR> EmailValid = true<BR> break;<BR> }<BR>}<BR>if (!EmailValid)<BR>{<BR> alert("The \"Email\" field is invalid, please try again. It must contain an \"@\" and a \".\".");<BR>;<BR> return (false);<BR>}<BR><BR>Thanks in adv<BR><BR>

  2. #2
    kevin Guest

    Default RE: Email Validation

    no offense, but for any decent email validation you should use regular expresions.<BR><BR>good luck.

  3. #3
    laffit Guest

    Default RE: Email Validation...and Kevin.

    Hi, go to this link<BR><BR>and download the text file at the bottom of the article. It has an email validation function in there as well as many other javascript validation functions.<BR><BR>btw, Kevin (person who replied to original post) if you are going to make smart *** remarks about what you consider to be "decent" programming, at least give an example or a link so that people can learn WHY they should listen to you.<BR><BR>enjoy<BR>~laffit!

Posting Permissions

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