« Return to Thread: "Form" is not a constructor

Re: RE: Re: "Form" is not a constructor

by Paul King :: Rate this Message:

Reply to Author | View in Thread

Here is a file which exhibits the error - just click on the button - change Form to Form1 in 2 places and it no longer breaks:

<html>
<head>
<script type="text/javascript">
<!--
var Form = {
  getElements: function(form) {
    form = $(form);
    var elements = new Array();
    for (tagName in Form.Element.Serializers) {
      var tagElements = form.getElementsByTagName(tagName);
      for (var j = 0; j < tagElements.length; j++)
        elements.push(tagElements[j]);
    }
    return elements;
  }
}
function validate() {
    currentForm = document.getElementById('formId');
    currentForm.field1.value="fred";
    return false;
}
// -->
</script>
</head>
<body>
   <form id='formId' name='formName'>
     <input type="text" name="field1" value="barney">
     <input type="button" type="submit" id="submit" onClick="validate()">
   </form>
</body>
</html>

If it helps, here is a WebTest script for clicking the link:

    <target name="main">
        <property name="testfile" location="checkJavaScript.html"/>
        <webtest name="prototype.js bug">
            <config
                    summary="true"
                    saveresponse="true"
                    showhtmlparseroutput="false"/>
            <steps>
                <invoke url="file:///${testfile}"/>
                <clickButton htmlId="submit" />
                <verifyInputField name="field1" value="fred"/>
            </steps>
        </webtest>
    </target>

 « Return to Thread: "Form" is not a constructor