From 0a5f103733236d41b0fc921264098180069a02c8 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Wed, 6 Jul 2011 15:43:50 -0400 Subject: check required on add previsouly was checked on key down, but that does the check too soon. Next attempt was on blur, but that had numerous problems. This now checkes when the add button is clicked. works for entity_select widget, too Checks upon form submission https://fedorahosted.org/freeipa/ticket/1437 --- install/ui/add.js | 11 ++++++-- install/ui/service.js | 1 + install/ui/widget.js | 71 ++++++++++++++++++++++++++------------------------- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/install/ui/add.js b/install/ui/add.js index 50b6124c0..0a414b74b 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -118,11 +118,14 @@ IPA.add_dialog = function (spec) { for (var i=0; i', { + name: 'error_link', + html: IPA.messages.widget.validation.error, + 'class': 'ui-state-error ui-corner-all', + style: 'display:none' + }).appendTo(container); + }; + that.check_required = function(){ var values = that.save(); - if (!values || !values.length) { + if (!values || !values.length || values[0] === '' ) { if (that.param_info && that.param_info.required && !that.optional) { that.valid = false; that.show_error(IPA.messages.widget.validation.required); + return false; } - return; } + return true; + }; + /*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() { + hide_error(); + that.valid = true; + + var values = that.save(); var value = values[0]; if (!value) { return; @@ -319,10 +331,10 @@ IPA.widget = function(spec) { error_link.css('display', 'block'); }; - that.hide_error = function() { + function hide_error() { var error_link = that.get_error_link(); error_link.css('display', 'none'); - }; + } that.set_enabled = function() { }; @@ -371,6 +383,7 @@ IPA.text_widget = function(spec) { IPA.select_range(that.input, start, end); }; + that.create = function(container) { $('