Using a text box and submit button, you can validate an e-mail address to make sure there is only one @ sign and that it is not at the beginning or end of the address. Also, you can check to ensure there is at least one period in the address and any periods are not at the beginning or end of the address. To do the validation, all you’ll need is the JavaScript String.indexOf() function. This searches a string and returns the first instance of a substring. Using indexOf() you can search either from the beginning or a specific starting point. This code also makes sure that the required period is after the required @ sign. Finally, you can give appropriate alert responses to whether the requirements have been met.