From f74b5775a4a5326ecd21290fe5f6c0e857f4045c Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sat, 12 Mar 2011 10:56:47 -0500 Subject: [PATCH] Synchronize: for the connection panel there was an inactive validation function; modified it, hopefully in a clearer way --- js/server_synchronize.js | 78 ++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/js/server_synchronize.js b/js/server_synchronize.js index e327a7b404..4857530dbe 100644 --- a/js/server_synchronize.js +++ b/js/server_synchronize.js @@ -254,50 +254,51 @@ function ApplySelectedChanges(token) location.href += append_string; } + +/** + * Validates a partial form (source part or target part) + * + * @param which 'src' or 'trg' + * @return boolean whether the partial form is valid + * + */ +function validateSourceOrTarget(which) +{ + var partial_form_is_ok = true; + + if ($("#" + which + "_type").val() != 'cur') { + // did not choose "current connection" + if ($("input[name='" + which + "_username']").val() == '' + || $("input[name='" + which + "_pass']").val() == '' + || $("input[name='" + which + "_db']").val() == '' + // must have at least a host or a socket + || ($("input[name='" + which + "_host']").val() == '' + && $("input[name='" + which + "_socket']").val() == '') + // port can be empty + ) { + partial_form_is_ok = false; + } + } + return partial_form_is_ok; +} /** * Displays an error message if any text field -* is left empty other than the port field. -* -* @param string the form name -* @param object the form +* is left empty other than the port field, unless +* we are dealing with the "current connection" choice * -* @return boolean whether the form field is empty or not +* @return boolean whether the form is valid */ -function validateConnection(form_name, form_obj) +function validateConnectionParams() { - var check = true; - var src_hostfilled = true; - var trg_hostfilled = true; - - for (var i=1; i