function trim(strText) {
    // this will get rid of leading spaces
    while (strText.substring(0,1)==String.fromCharCode(32)){
        strText = strText.substring(1, strText.length);
        // this will get rid of trailing spaces
    }
    while (strText.substring(strText.length-1,strText.length)==String.fromCharCode(32)){
        strText = strText.substring(0, strText.length-1);
    }
    return strText;
}

// Field validation function
function validate(form)
{
        var err_str = "";

        if (trim(form.email.value) == "")
        {
                alert("กรุณาใส่อีเมล์");
                form.email.focus();
                return false;
        }

        form.submit();
        return true;
}
