HoloGuides :: Know Everything ! Knowledge
Programming
JavaScript . email validation



Guide / Tutorial
Browser elements
.status, .address, .tools, ...
NN / IE
.
Viewable Area

Form elements
.text, .button, .onChange, ...

Table elements
.TR, .TD, .border, ...

Windows functions
.open (pop-up), ...

User Interface
. preloading images
Output
. Alert boxes
.
Status bar
. Windows
Input
. Keyboard Entries
. Mouse Events
.
Form elements
. Input Validation
. - Email Validation
. -
Number Validation
Programming
. Conditions [If-(Then)-Else]
. Variables & Arrays
. Functions & Parameters
. Loops
DHTML and DOM
. Windows
. - Frames
. Forms
. Tables
. Style Sheets

References
. JavaScript Syntax
. ECMA Script
. Object Oriented Programming
. Recursive Programming
Netscape Language Reference

Email Validation

email

Check for correct syntax of a given email address.
function CyJS_Utils_IsEmailValid(checkThisEmail)
{
var myEMailIsValid = true;
var myAtSymbolAt = checkThisEmail.indexOf('@');
var myLastDotAt = checkThisEmail.lastIndexOf('.');
var mySpaceAt = checkThisEmail.indexOf(' ');
var myLength = checkThisEmail.length;


// at least one @ must be present and not before position 2
// @yellow.com : NOT valid
// x@yellow.com : VALID


if (myAtSymbolAt < 1 )
 {myEMailIsValid = false}


// at least one . (dot) afer the @ is required
// x@yellow : NOT valid
// x.y@yellow : NOT valid
// x@yellow.org : VALID


if (myLastDotAt < myAtSymbolAt)
 {myEMailIsValid = false}

// at least two characters [com, uk, fr, ...] must occur after the last . (dot)
// x.y@yellow. : NOT valid
// x.y@yellow.a : NOT valid
// x.y@yellow.ca : VALID

if (myLength - myLastDotAt <= 2)
 {myEMailIsValid = false}


// no empty space " " is permitted (one may trim the email)
// x.y@yell ow.com : NOT valid


if (mySpaceAt != -1)
 {myEMailIsValid = false}


if (myEMailIsValid == true)
 {alert("email is VALID")}
else
 {alert("email is NOT valid!")}


return myEMailIsValid
}