From add7d701c688be4d9699034427e5ab1be67a8bac Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Sun, 23 Jan 2011 07:41:10 +0700 Subject: Check field's validity before executing add. --- install/ui/widget.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index 90f6dac8..f34532d2 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -46,6 +46,7 @@ IPA.widget = function(spec) { that.save = spec.save || save; that.update = spec.update || update; that.validate_input = spec.validate_input || validate_input; + that.valid = true; that.param_info = spec.param_info; that.__defineGetter__("entity_name", function(){ @@ -61,23 +62,25 @@ IPA.widget = function(spec) { displays the error message and returns false. */ function validate_input(text) { if (!(that.param_info && that.param_info.pattern)) { - return true; + that.valid = true; + return; } var error_link = that.get_error_link(); if (!error_link) { - return true; + that.valid = true; + return; } var regex = new RegExp( that.param_info.pattern ); //If the field is empty, don't validate if ( !text || text.match(regex) ) { error_link.css('display', 'none'); - return true; + that.valid = true; }else{ error_link.css('display', 'block'); if (that.param_info.pattern_errmsg) { error_link.html(that.param_info.pattern_errmsg); } - return false; + that.valid = false; } } -- cgit