validate email address from string

handy for a simple email verification in a form submit

var emailfield = $("#emailfield").val();
var atpos = emailfield.indexOf("@");
var dotpos = emailfield.lastIndexOf(".");
if (atpos<1 || dotpos=emailfield.length) {
    alert("Not a valid e-mail address");
    return false;
}  

Demo

Other Items in js
Page Views

This page has been viewed 48 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹