diff --git a/install/ui/dialog.js b/install/ui/dialog.js index f60db5cab..2c9fdb0e2 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -74,11 +74,19 @@ IPA.dialog = function(spec) { that.fields_by_name[field.name] = field; }; - that.field = function(field){ + that.field = function(field) { that.add_field(field); return that; }; + that.is_valid = function() { + for (var i=0; i that.metadata.maxvalue) { + that.valid = false; + // TODO: I18n + that.show_error('maximum value is '+that.metadata.maxvalue); + return; + } } - that.valid = false; } - } + + if (that.param_info) { + if (that.param_info.pattern) { + var regex = new RegExp(that.param_info.pattern); + if (!value.match(regex)) { + that.valid = false; + that.show_error(that.param_info.pattern_errmsg); + return; + } + } + } + }; function init() { if (that.entity_name) { @@ -247,12 +278,13 @@ IPA.widget = function(spec) { return $('span[name="error_link"]', that.container); }; - that.show_error_link = function() { + that.show_error = function(message) { var error_link = that.get_error_link(); - error_link.css('display', 'inline'); + error_link.html(message); + error_link.css('display', 'block'); }; - that.hide_error_link = function() { + that.hide_error = function() { var error_link = that.get_error_link(); error_link.css('display', 'none'); }; @@ -323,8 +355,7 @@ IPA.text_widget = function(spec) { if (that.undo) { that.show_undo(); } - var value = $(this).val(); - that.validate_input(value); + that.validate(); }); var undo = that.get_undo(); @@ -539,8 +570,7 @@ IPA.multivalued_text_widget = function(spec) { remove_link.css('display', 'inline'); } } - var value = $(this).val(); - that.validate_input(value); + that.validate(); }); remove_link.click(function() { @@ -965,9 +995,7 @@ IPA.textarea_widget = function (spec) { var input = $('textarea[name="'+that.name+'"]', that.container); input.keyup(function() { that.show_undo(); - - var value = $(this).val(); - that.validate_input(value); + that.validate(); });