function updatecomment() {
     if(document.myform.authorid.value.length==0||
        document.myform.emailaddr.value.length==0||
        document.myform.comment.value.length==0) {
        alert("can not submit form");
        return false;
     }
     var e=/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/.exec(document.myform.emailaddr.value);
     if(e==null){
        alert("invalid email address");
        return false;
     }
     if(document.myform.comment.value.length>2048){
        alert("comment can not longer than 2048 characters!");
        return false;
     }
     var curdate = new Date();
     document.myform.comment.value.replace("<","<");
     document.myform.comment.value.replace(">",">");
        document.myform.text.value="<commblock>\n<author>"+document.myform.authorid.value+"</author>\n";
        document.myform.text.value+="<email>"+document.myform.emailaddr.value+"</email>\n";
        document.myform.text.value+="<inst>"+document.myform.inst.value+"</inst>\n";
        document.myform.text.value+="<comment>\n"+document.myform.comment.value+"\n</comment>\n";
     document.myform.text.value+="<timestamp>: "
               +curdate.toString()+"</timestamp>\n</commblock>\n";
        return true;
} function submitform() {
        if(updatecomment()!=false)
                document.myform.submit();
} function doemail() {
        document.getElementById("do_email_notify").checked=true;
} window.onload=doemail;
Powered by Habitat