Alazanto

Validating the Comments Template

Filed Under: Site Updates, Journal.

As I am tweaking each of my templates for conformance with the XHTML 1.1 spec, I faced a challenge with the comments template. The “form” element contains the “name” property rather than the “id” property. For the latest versions of XHTML, “name” is no longer supported.

For this reason, one is safe to specify the following under the condition in which the “bake-cookie” javascript is updated to target the form element by ID, rather than name.

<form method=\"post\" action=\"<$MTCGIPath$><$MTCommentScript$>\"id=”comments_form” onsubmit=”if (this.bakecookie[0].checked) rememberMe(this)”>

The following is the modified javascript.

<script type=\"text/javascript\">
	
document.getElementById(’comments_form’).email.value = getCookie(”mtcmtmail”);
	
document.getElementById(’comments_form’).author.value = getCookie(”mtcmtauth”);
	
document.getElementById(’comments_form’).url.value = getCookie(”mtcmthome”);
	
if (getCookie(”mtcmtauth”)) {    document.getElementById(’comments_form’).bakecookie.checked = true;} else {    document.getElementById(’comments_form’).forget.checked = true;}
	
</script>

In the script, I simply used “document.getElementById('’)” to target the form. Once this script is implemented, the “bakecookie” script will work as expected. I think.

Published: 4 years, 4 months ago