function check(form) {
    if (form.username.value.length == 0)
        return comment("Please input a username");
    if (form.password.value != form.password2.value) 
        return comment("Passwords don't match!");
    if (form.password.value.length < 4) 
        return comment("Please select a longer password");
    if (form.imei.value.length != 15 || !isInt(form.imei.value))
        return comment("Please check imei.");
    return true;
}

function comment(text) {
    document.getElementById("comments").innerHTML = text;
    return false;
}

function isInt(imei) {
    var x = parseInt(imei);
    if (isNaN(x))
        return false;
    x = x.toString();
    if (x != imei)
        return false;
    return true;
}