Updated comment script

One of the things that’s always annoyed me with Movable Type’s default templates, is that the Javascripts for automatically filling in the user data in comment forms haven’t been very clean. I have modified the script to please my own demands for aestethics and pure markup.

The default javascript has always addressed form values on the form document.formName.formElement whereas document.forms['formName'].elements['formElement'] is the clean and recommended way to do it. I have corrected all of this.
The default scripts have always had a section of <script> right after the form. I think this is semantically ugly, because it implies that the Javascript is, or generates part of the content, which it most certainly does not. I have moved this into a function which is called onload of the page instead.
Beside that, I have also moved the script to an external file, being referenced by <script src="filename.js" ></script> – this way you can use the same script for both pop-up and normal comments.
h3. Instructions for use
# “Download the script”:http://virtuelvis.com/download/comments.js.
# For convenience, I have created the script as an index template. Should you choose to use it otherwise, replace <$MTBlogHost$> with your blog’s domain name.
# Remove any references to the comments javascript from your individual entry template, comment listing template and comment preview template and insert this into the head of your templates: <script type="text/javascript" src="<$MTLink template='CommentScript'$>"></script> where src references either your template file like this, or the URL directly, if you chose not to use an index template.
# Right after the comment form, there is a script snippet. Remove this.
# (Optional) Your comment form has an onsubmit-event. Change this to: onsubmit="if (this.elements['bakecookie'][0].checked) rememberMe(this);"
Really, that’s all. Should you have any questions, or suggestions, feel free to ask.

Leave a comment


  1. I’m having trouble making this work and wanted to post a test on this page to see if it works here. I’m using Mac IE5.15

  2. So, did it work?

  3. Fine now. Got it working. BTW, you need to pass along the comment body in your form on the preview page. Thanks so much for sharing this! I prefer to separate my scripts from my html but didn’t know how with this one — until now.

  4. Comment preview fixed.

  5. cow

     /  2003-06-26

    hi im back. i have no clue on how to work this script, can you e-mail me or something and help me please?

  6. I’m sorry, I generally don’t do e-mail support. If you’re running Movable Type, following the instructions carefully step by step should be straightforward enough.

  7. Tim

     /  2003-06-26

    what is “blog’s domain name”?

  8. For this blog, it would for instance be _virtuelvis.com_.

  9. I was wondering if this script HAS to be used with blogs such as movabletype or greymatter?

  10. This is addictive.

    coverting to MySQL 官方版的說明文件少寫了兩個é‡�點: mt.cfg è¦�ä¿�留原先 Berkeley DB çš„å…©è¡Œ DataSource,…