<SCRIPT type="text/JavaScript">
<!-- Begin
function signForm(theForm, theWindow, validation, varnames) {
    //header text
   var texttbs = "I affirm the following information:\n";
    //header text, spanish version
    //var texttbs = "Certifico que la siguiente informacion es cierta:\n";
   var vars = "";        //to store variable names
   var signature = "";   //to store the digital signature of texttbs
   var elem;
   var formSize = theForm.elements.length;
   for(var i = 0; i < formSize; i++) {
      elem = theForm.elements[i];
      switch (elem.type) {
         case "hidden":
         case "button":
         case "submit":
         case "reset":
         case "image":
         case "password":
         case "file":
            // Do not include previous elements in the text to be signed.
            break;
         case "select-one":
            var selectValue = elem.options[elem.selectedIndex].value;
            texttbs += elem.name + "=" + selectValue + "\n";
            vars += elem.name + ",";
            break;
         case "select-multiple":
            for(var op = 0; op < elem.length; op++) {
               if(elem.options[op].selected) {
                  texttbs += elem.name + "=" + elem.options[op].value + "\n";
                  vars += elem.name + ",";
               }
            }
            break;
         case "radio":
            if(elem.checked) {
               texttbs += elem.name + "=" + elem.value + "\n";
               vars += elem.name + ",";
            }
            break;
         case "checkbox":
            if(elem.checked) {
               texttbs += elem.name + "=" + elem.value + "\n";
               vars += elem.name + ",";
            }
            break;
         //In the case of unchecked radio buttons and checkboxes, variables
         //are not sent, hence they must not be signed.
         default: //input text
            texttbs += elem.name + "=" + elem.value + "\n";
            vars += elem.name + ",";
      }
   }
   //Digital signature
   signature = theWindow.crypto.signText(texttbs, "ask");
   if (signature.substr(0,5)=="error") {
      alert("Signature not created\n" + signature);
      return false;
   }
   //Store signature an vars in hidden inputs of the form
   theForm.signature.value = signature;
   theForm.varnames.value= vars;
   return true;
}
// End -->
</script>
Listing One: Definition of signForm function