// JavaScript Document
// check integer 
function isFormInt(elm) {
var elmstr = elm.value + ""; 
    if (elmstr == "") return false;
    for (var i = 0; i < elmstr.length; i++) {
        if (elmstr.charAt(i) < "0" ||
            elmstr.charAt(i) > "9") {
        return false;
        }
    }
return true;
}
 
function isEmail(email) {
    invalidChars = " ~\'^\`\"*+=\\|][(){}$&!#%/:,;";
    // Check for null
    if (email == "") {
        return false;
    }
    // Check for invalid characters as defined above
    for (i=0; i<invalidChars.length; i++) {
        badChar = invalidChars.charAt(i);
        if (email.indexOf(badChar,0) > -1) {
            return false;
        }
    }
    lengthOfEmail = email.length;
    if ((email.charAt(lengthOfEmail - 1) == ".") || (email.charAt(lengthOfEmail - 2) == ".")) {
        return false;
    }
    Pos = email.indexOf("@",1);
    if (email.charAt(Pos + 1) == ".") {
        return false;
    }
    while ((Pos < lengthOfEmail) && ( Pos != -1)) {
        Pos = email.indexOf(".",Pos);
        if (email.charAt(Pos + 1) == ".") {
            return false;
        }
        if (Pos != -1) {
            Pos++;
        }
    }
    atPos = email.indexOf("@",1);
    if (atPos == -1) {
        return false;
    }
    if (email.indexOf("@",atPos+1) != -1) {
        return false;
    }
    periodPos = email.indexOf(".",atPos);
    if (periodPos == -1) {
        return false;
    }
    if (periodPos+3 > email.length) {
        return false;
    }
    return true;
}

