For a client we're exporting all the address information that goes into Magento into a third party processing system. The details about this is unimportant - but what is important is that things go terribly wrong if fields are longer than an expected amount of characters.

For this reason, we're using the API with substr in order to truncate the data down to the expected size - but this isn't really good enough. The staff using the admin panel is apparently of a decent size and can't be trained to use it correctly, so we also need to apply this limitations to the admin panel itself.

As we don't really care about them using technical know-how to get past these limitations, all we really need is a maxlength="x" on the form elements. **It is a requirement that different form elements may have different maxlengths**.

**What is the cleanest, most upgrade-proof way to enforce a maximum length on the customer address fields in the admin panel?**

My first thought was using JavaScript - but the fields don't have really predictable identifiers, so I'm not sure I can easily. Because they all use the form rendering stuff, I also can't just edit a template file by creating a custom admin theme.

Phrased another way: **What's the easiest and cleanest way to add a maxlength attribute to these fields?**