Set field length with java

While using an open text list, this will set the max length of each of the fields in the list, as standard confirmit will set the length for all of the fields with one box, use this if each one differs in length.
document.getElementById(“ContactDetails2_Main”).maxLength = “20“;
document.getElementById(“ContactDetails2_Alt“).maxLength = “25“;
Parts in bold are the field names, and length with the number.