Index: trunk/lib/Text/FormBuilder.pm
===================================================================
--- trunk/lib/Text/FormBuilder.pm	(revision 55)
+++ trunk/lib/Text/FormBuilder.pm	(revision 56)
@@ -624,5 +624,8 @@
 =head1 REQUIRES
 
-L<Parse::RecDescent>, L<CGI::FormBuilder>, L<Text::Template>
+L<Parse::RecDescent>,
+L<CGI::FormBuilder>,
+L<Text::Template>,
+L<Class::Base>
 
 =head1 DESCRIPTION
@@ -1043,4 +1046,12 @@
     description[4,30]:textarea
 
+To also set the C<maxlength> attribute for text fields, add a C<!> after
+the size:
+
+    # ensure that all titles entered are 40 characters or less
+    title[40!]:text
+
+This currently only works for single line text fields.
+    
 For the input types that can have options (C<select>, C<radio>, and
 C<checkbox>), here's how you do it:
Index: trunk/lib/Text/FormBuilder/grammar
===================================================================
--- trunk/lib/Text/FormBuilder/grammar	(revision 55)
+++ trunk/lib/Text/FormBuilder/grammar	(revision 56)
@@ -19,4 +19,5 @@
 	$list_var,
 	$size,
+	$maxlength,
 	$rows,
 	$cols,
@@ -157,4 +158,5 @@
 	$$field{cols} = $cols if defined $cols;
 	$$field{size} = $size if defined $size;
+	$$field{maxlength} = $maxlength if defined $maxlength;
 	
 	#warn "[$thisline] field $item{name}; context $context\n";
@@ -171,4 +173,5 @@
 	$rows = undef;
 	$cols = undef;
+	$maxlength = undef;
 	@options = ();
         
@@ -181,6 +184,8 @@
 field_size: '[' ( row_col | size ) ']'
 
-size: /\d+/
-    { $size = $item[1] }
+size: /\d+/ bang(?)
+    { $maxlength = $item[1] if $item[2][0]; $size = $item[1] }
+
+bang: '!'
 
 row_col: /\d+/ /,\s*/ /\d+/
