From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci/cluster form-macros validate_qdisk. ...
Date: 16 Aug 2006 23:02:27 -0000 [thread overview]
Message-ID: <20060816230227.2681.qmail@sourceware.org> (raw)
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 @@
</ul>
<div id="configTabContent" tal:condition="python: configTabNum == 1">
- <form name="basecluster" action="" method="get"
- tal:attributes="action clusterinfo/basecluster_url">
+ <script type="text/javascript" src="/luci/homebase/homebase_common.js"></script>
+ <script type="text/javascript" src="/luci/cluster/validate_config_general.js"></script>
+ <form name="basecluster" action="" method="post">
<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
<thead class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="1">
@@ -349,7 +350,7 @@
<tr class="systemsTable">
<td class="systemsTable" colspan="2">
<div class="systemsTableEnd">
- <input type="submit" value="Apply"/>
+ <input type="button" value="Apply" onClick="validate_form(this.form);"/>
</div>
</td>
</tr>
--- 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.');
}
reply other threads:[~2006-08-16 23:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060816230227.2681.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).