HaloScan Commenting and Trackback

racdaroucn
ousitca
olovar

Making form fields mandatory


*PREMIUM MEMBERS ONLY*

If you are not comfortable editing your template and working with HTML code please do not proceed. The code provided is used at your discretion and is not a formal part of the HaloScan offering

This can be done easily by using Javascript to check that the fields in the comment form have been filled in before allowing a comment to be posted. To do this you'll need to edit your HaloScan comment template, and add in the required Javascript.

The instructions below will check that the NAME field has been completed. See below for email and URL instructions.

To ensure a Name is mandatory:
  1. From the main HaloScan page, select Template Gallery.
  2. In the middle of the page, select the HTML tab.
  3. In the code displayed, locate the </head> tag.
  4. Immediately before that tag, paste the following code
<script language="javascript1.2" type="text/javascript">
<!--
function checkform ( form ) {
 if (form.name.value == "") {
   alert( "Please enter your name" );
   form.name.focus();
   return false;
 }
 return true;
}
//-->

</script>

  1. Next, locate the {HSFormStart} tag, usually about halfway down the code.
  2. Delete that tag and in it's place, paste the following
<form method="post" name="addComment" action="comments.php" onsubmit="return checkform(this);" target="_self">

  1. Under the code area, click Save.

You can now preview the saved template to see if the changes have worked. If not select Reset to Default to Template.

To make the email field mandatory repeat step 4, replacing form.name.value and form.name.focus with form.email.value and form.email.focus respectively.

To make the URL field mandatory repeat step 4, replacing form.name.value and form.name.focus with form.URL.value and form.URL.focus respectively.




Taken from the forums
Page was generated in 0.1286 seconds