2005-07-14

Custom Blogger comments form submit listener fixed

I have fixed the custom Blogger comments form. I changed the submit listener because of a bug in it. In the old situation I used addEventListener to set the submit listener:

if (cFrm.addEventListener) {
  cFrm.addEventListener('submit', function(){return cFrmPost()}, false);
} else {
  cFrm.onsubmit = function(){return cFrmPost()};
}

addEventListener doesn't return the cFrmPost() return value. When you left the name field blank, you would be asked to fill in a name. At the same time the comment was posted as 'Anonymous'. Now I just use:

cFrm.onsubmit = function(){return cFrmPost()};

Thanks to Hinderik for pointing this out.

No comments: