How to check E - Mail format

I created two input box, one for “Name” and one for “E-mail address”,

I am wondering, when a user enter he or her E-mail address, how can I check the format, for example the E -Mail address " must contain " @ "

could anyone tell me how could I do that

thank you very much

use indexOf(); to check for a character within a string. If the character isn’t present it’ll return -1, else it will return the characters position/index withing the string.


if(EMail.indexOf("@") != -1 && EMail.indexOf(".") != -1) {
      // Email is valid
}else {
      // Email is not valid

hope this helps

thank you very much

no problem. :wink: