0

I have a Struts File control in my page. I would like to reset my file control if there is an invalid entry. Following are the things i noticed: 1) Most browsers don't let us to reset the file control. 2) What we can do is replace the existing control with a new control and copy all the original control's properties. I did this by doing :

var newInput = document.createElement("input");
    newInput.type = "file";
    newInput.id = document.getElementById("myfilecontrol").id;
    newInput.name = document.getElementById("myfilecontrol").name;
    newInput.className = document.getElementById("myfilecontrol").className;
    newInput.style.cssText = document.getElementById("myfilecontrol").style.cssText;
    document.getElementById("myfilecontrol").parentNode.replaceChild(newInput, document.getElementById("myfilecontrol"));

My problem is that this works only once. It is the old control that calls the validation method and not the new one. Is there any way i can make my new control call the validation method automatically ? or is there another better way to reset a struts file control ? (Refreshing the page is not an option.) Thanks in advance.

antony.ouseph.k
  • 907
  • 2
  • 15
  • 28

0 Answers0