From cd7badadc666745ea4283f96f463140a626984b9 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Wed, 6 Jul 2011 15:43:50 -0400
Subject: [PATCH] check required on blur

previsouly was checked on key down, but that does the check too soon.

https://fedorahosted.org/freeipa/ticket/1437
---
 install/ui/widget.js |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/install/ui/widget.js b/install/ui/widget.js
index cd3a5c60e2153b25c0fce58ebaf94cf3f51f1ffe..57d34bed3b243d21eb56434c3bdae4cb428f0aaa 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -108,26 +108,26 @@ IPA.widget = function(spec) {
 
     }
 
+    that.check_required = function(){
+        var values = that.save();
+        if (!values || !values.length) {
+            if (that.param_info &&
+                that.param_info.required &&
+                !that.optional) {
+                that.valid = false;
+                that.show_error(IPA.messages.widget.validation.required);
+            }
+        }
+    };
+
     /*returns true and clears the error message if the field value  passes
       the validation pattern.  If the field value does not pass validation,
       displays the error message and returns false. */
     that.validate = function() {
-
         that.hide_error();
-
         that.valid = true;
 
         var values = that.save();
-        if (!values || !values.length) {
-            if (that.param_info &&
-                that.param_info.required &&
-                !that.optional) {
-                that.valid = false;
-                that.show_error(IPA.messages.widget.validation.required);
-            }
-            return;
-        }
-
         var value = values[0];
         if (!value) {
             return;
@@ -411,6 +411,10 @@ IPA.text_widget = function(spec) {
             that.validate();
         });
 
+        input.blur(function(){
+            that.check_required();
+        });
+
         var undo = that.get_undo();
         undo.click(function() {
             that.reset();
-- 
1.7.5.2

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to