Search code examples
javascriptstrutsstruts-1

How to add new attribute to Struts 1 <s:form>?


This is document from Zurb abide validation tool: http://foundation.zurb.com/docs/components/abide.html#setting-up-validation

I use Struts 1 form, and try something like this:

<s:form styleId="frmAddEstate" action="${addEstateProfile}" data-abide>
    // input fields...
</s:form>

but not working. Please help me put "data-abide" to form tag. (I think we will revise file *.tld - tag lib definition).


Solution

  • You can use javascript to add attributes to the form when it has been loaded.

    document.getElementById("frmAddEstate").onload = function() {myFunction()};
    
    function myFunction() {
      var att = document.createAttribute("data-abide");
      document.getElementById("frmAddEstate").setAttributeNode(att);
    }