Index: /trunk/data/defaultpresets.xml
===================================================================
--- /trunk/data/defaultpresets.xml	(revision 5578)
+++ /trunk/data/defaultpresets.xml	(revision 5579)
@@ -36,4 +36,5 @@
   use_last_as_default: true/false/force (default is "false")
   match: none/key/key!/keyvalue (default is "none", see below for more information)
+  length: length of input box (number of characters allowed)
 
 combo: combo box, with multiple choices and possible to enter free form text
Index: /trunk/data/tagging-preset.xsd
===================================================================
--- /trunk/data/tagging-preset.xsd	(revision 5578)
+++ /trunk/data/tagging-preset.xsd	(revision 5579)
@@ -118,4 +118,5 @@
 		<attribute name="use_last_as_default" type="tns:last_default" />
 		<attribute name="match" type="tns:match" />
+        <attribute name="length" type="positiveInteger" />
 
 		<attribute name="type" use="prohibited" />
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 5578)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 5579)
@@ -378,4 +378,5 @@
         public String originalValue;
         public String use_last_as_default = "false";
+        public String length;
 
         private JComponent value;
@@ -387,4 +388,7 @@
             AutoCompletingTextField textField = new AutoCompletingTextField();
             initAutoCompletionField(textField, key);
+            if (length != null && !length.isEmpty()) {
+                textField.setMaxChars(new Integer(length));
+            }
             if (usage.unused()){
                 if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) {
Index: /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java	(revision 5578)
+++ /trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java	(revision 5579)
@@ -33,4 +33,7 @@
  */
 public class AutoCompletingTextField extends JTextField implements ComboBoxEditor, TableCellEditor {
+
+    private Integer maxChars;
+    
     /**
      * The document model for the editor
@@ -44,4 +47,15 @@
         @Override
         public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
+            
+            // If a maximum number of characters is specified, avoid to exceed it
+            if (maxChars != null && str != null && getLength() + str.length() > maxChars) {
+                int allowedLength = maxChars-getLength();
+                if (allowedLength > 0) {
+                    str = str.substring(0, allowedLength);
+                } else {
+                    return;
+                }
+            }
+            
             if (autoCompletionList == null) {
                 super.insertString(offs, str, a);
@@ -195,4 +209,13 @@
     }
 
+    /**
+     * Sets the maximum number of characters allowed.
+     * @param max maximum number of characters allowed
+     * @since 5579
+     */
+    public void setMaxChars(Integer max) {
+        maxChars = max;
+    }
+
     /* ------------------------------------------------------------------------------------ */
     /* TableCellEditor interface                                                            */
