From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 16 Aug 2006 23:02:27 -0000 Subject: [Cluster-devel] conga/luci/cluster form-macros validate_qdisk. ... Message-ID: <20060816230227.2681.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2006-08-16 23:02:27 Modified files: luci/cluster : form-macros validate_qdisk.js Added files: luci/cluster : validate_config_general.js Log message: more javascript form validation Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_general.js.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.47&r2=1.48 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_qdisk.js.diff?cvsroot=cluster&r1=1.1&r2=1.2 /cvs/cluster/conga/luci/cluster/validate_config_general.js,v --> standard output revision 1.1 --- conga/luci/cluster/validate_config_general.js +++ - 2006-08-16 23:02:27.256146000 +0000 @@ -0,0 +1,31 @@ +function validate_form(form) { + var errors = new Array(); + var name = null; + var ver = null; + + if (!form.cluname || str_is_blank(form.cluname.value)) + errors.push('You did not specify a cluster name.'); + else + name = form.cluname.value; + + if (!form.cfgver || str_is_blank(form.cfgver.value)) + errors.push('You did not specify a configuration version.'); + else + ver = form.cfgver.value; + + if (ver && !is_valid_int(ver, 0, null)) { + errors.push('The configuration version must be an integer greater than 0.'); + /* TODO: further restrictions? */ + } + + if (name) { + /* TODO: check this. */; + } + + if (error_dialog(errors)) + return (-1); + + if (confirm('Update general cluster properties?')) + form.submit(); + return (null); +} --- conga/luci/cluster/form-macros 2006/08/16 21:48:38 1.47 +++ conga/luci/cluster/form-macros 2006/08/16 23:02:27 1.48 @@ -319,8 +319,9 @@
-
+ + + --- conga/luci/cluster/validate_qdisk.js 2006/08/16 21:33:49 1.1 +++ conga/luci/cluster/validate_qdisk.js 2006/08/16 23:02:27 1.2 @@ -41,10 +41,10 @@ } /* TODO: hname, hpath */ - if (hint && isNaN(parseInt(hint))) - errors.push('Heuristic interval values must be integers.'); + if (hint && !is_valid_int(hint, 1, null)) + errors.push('Heuristic interval values must be integers greater than 0.'); - if (hscore && isNaN(parseInt(hscore))) + if (hscore && !is_valid_int(hscore, null, null)) errors.push('Heuristic score values must be integers.'); if (errors.length > 0) @@ -73,28 +73,28 @@ if (!form.interval || str_is_blank(form.interval.value)) errors.push('No interval setting was given.'); else { - if (isNaN(parseInt(form.interval.value))) - errors.push('Interval values must be integers.'); + if (!is_valid_int(form.interval.value, 1, null)) + errors.push('Interval values must be integers greater than 0.'); } if (!form.votes || str_is_blank(form.votes.value)) errors.push('No votes setting was given.'); else { - if (isNaN(parseInt(form.votes.value))) + if (!is_valid_int(form.votes.value, null, null)) errors.push('Votes values must be integers.'); } if (!form.tko || str_is_blank(form.tko.value)) errors.push('No TKO setting was given.'); else { - if (isNaN(parseInt(form.tko.value))) + if (!is_valid_int(form.tko.value, null, null)) errors.push('TKO values must be integers.'); } if (!form.min_score || str_is_blank(form.min_score.value)) errors.push('No minimum score setting was given.'); else { - if (isNaN(parseInt(form.tko.value))) + if (!is_valid_int(form.min_score.value, null, null)) errors.push('Minimum score values must be integers.'); }
@@ -349,7 +350,7 @@
- +