Index: core/data/defaultpresets.xml
===================================================================
--- core/data/defaultpresets.xml	(revision 5576)
+++ core/data/defaultpresets.xml	(working copy)
@@ -35,6 +35,7 @@
   default: default string to display (defaults to "")
   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
   key: key to set
Index: core/data/tagging-preset.xsd
===================================================================
--- core/data/tagging-preset.xsd	(revision 5576)
+++ core/data/tagging-preset.xsd	(working copy)
@@ -117,6 +117,7 @@
 		<attribute name="default" type="string" />
 		<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" />
 		<attribute name="name" use="prohibited" />
Index: core/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
===================================================================
--- core/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 5576)
+++ core/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(working copy)
@@ -377,6 +377,7 @@
         public String default_;
         public String originalValue;
         public String use_last_as_default = "false";
+        public String length;
 
         private JComponent value;
 
@@ -386,6 +387,9 @@
             Usage usage = determineTextUsage(sel, key);
             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)) {
                     // selected osm primitives are untagged or filling default values feature is enabled
Index: core/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java
===================================================================
--- core/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java	(revision 5576)
+++ core/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletingTextField.java	(working copy)
@@ -32,6 +32,9 @@
  *
  */
 public class AutoCompletingTextField extends JTextField implements ComboBoxEditor, TableCellEditor {
+
+    private Integer maxChars;
+    
     /**
      * The document model for the editor
      */
@@ -43,6 +46,17 @@
          */
         @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);
                 return;
@@ -194,6 +208,15 @@
         }
     }
 
+    /**
+     * Sets the maximum number of characters allowed.
+     * @param max maximum number of characters allowed
+     * @since 5577
+     */
+    public void setMaxChars(Integer max) {
+        maxChars = max;
+    }
+
     /* ------------------------------------------------------------------------------------ */
     /* TableCellEditor interface                                                            */
     /* ------------------------------------------------------------------------------------ */
