Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-1903

Client side javascript validation has javascript errors when textfield labelposition is set to top

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.6
    • 2.1.0
    • Other
    • None
    • JDK1.5.0_09, JBoss 4.0.5, Windows XP SP2

    Description

      Using client side pure javascript field validation results in [Object Error] alert box in IE and "TypeError: label has no properties" alert box in FF.

      <s:form action="authenticate" validate="true">
      <s:textfield key="login.name" name="name" value="%

      {name}

      " tabindex="1" labelposition="top"/>
      <s:password key="login.password" name="password" tabindex="2" labelposition="top"/>
      <s:submit type="image" src="images/goButton.gif" tabindex="3"/>
      </s:form>

      I've isolated the error to the following method in validation.js:

      function addError(e, errorText) {
      try

      { // clear out any rows with an "errorFor" of e.id var row = e.parentNode.parentNode; var table = row.parentNode; var error = document.createTextNode(errorText); var tr = document.createElement("tr"); var td = document.createElement("td"); var span = document.createElement("span"); td.align = "center"; td.valign = "top"; td.colSpan = 2; span.setAttribute("class", "errorMessage"); span.setAttribute("className", "errorMessage"); //ie hack cause ie does not support setAttribute span.appendChild(error); td.appendChild(span); tr.appendChild(td); tr.setAttribute("errorFor", e.id);; table.insertBefore(tr, row); // updat the label too var label = row.cells[0].getElementsByTagName("label")[0]; label.setAttribute("class", "errorLabel"); label.setAttribute("className", "errorLabel"); //ie hack cause ie does not support setAttribute }

      catch (e)

      { alert(e); }

      }

      I've worked around it by comparing 'label' to null.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            musachy Musachy Barroso
            rshan Robert Shanahan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment