Index: main/widget/textbox.lisp
===================================================================
--- main/widget/textbox.lisp	(revision main,65)
+++ main/widget/textbox.lisp	(revision main,80)
@@ -10,4 +10,5 @@
 (defclass textbox (widget scroll insertion-point)
   ((data :initarg :data)
+   (validator :initform 'identity :initarg :validator :reader validator)
    (window :initarg :window)
    (active :type boolean :initform nil)))
@@ -63,13 +64,10 @@
 
 
-(defun create-textbox (parent-window y x data width &key
+(defun create-textbox (parent-window y x data width &rest args &key validator
                        (inactive-background '(#\Space 0))
                        (active-background '(#\Space 0)))
+  (declare (ignore validator inactive-background active-background))
   (let* ((window (tui-window::create-subwindow parent-window 1 width y x))
-         (inst (make-instance 'textbox
-                              :data data
-                              :window window
-                              :inactive-background inactive-background
-                              :active-background active-background)))
+         (inst (apply 'make-instance 'textbox :data data :window window args)))
     (draw inst)
     inst))
@@ -123,6 +121,9 @@
                        (let ((r (funcall key-callback key)))
                          (when r
-                           (setf (insertion-point textbox) 0)
-                           (return-from activate r)))
+                           (let ((q (funcall (validator textbox) (text data))))
+                             (when q
+                               (setf (text data) q)
+                               (setf (insertion-point textbox) 0)
+                               (return-from activate r)))))
                        (multiple-value-bind (left right) (split textbox)
                          (setf (text data)
