- do some basic checking in JS for the limit value supplied

This commit is contained in:
ccooper%deadsquid.com 2006-01-30 23:06:56 +00:00
parent 332d54ef86
commit cec32647a3
3 changed files with 35 additions and 3 deletions

View File

@ -1,4 +1,5 @@
var iBugNumber = "This field must be a valid, positive integer (>0). Please re-enter it now.";
var iNumber = iBugNumber;
var iEmail = "This field must be a valid email address (like foo@bar.com). Please re-enter it now.";
var iBuildId = "This field must be a valid build id, which is a string of 8 digits most easily found in the About dialog. Please re-enter it now.";
var iPasswordMismatch = "The passwords you entered did not match.";
@ -208,6 +209,24 @@ function checkBuildId (theField, emptyOK)
}
}
// checkNumber (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid, positive integer.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
function checkNumber (theField, emptyOK)
{
if (checkNumber.arguments.length == 1) {
emptyOK = defaultEmptyOK;
}
if (isPositiveInteger(theField.value,emptyOK)) {
return true;
} else {
return warnInvalid (theField, iNumber);
}
}
// isInteger (STRING s [, BOOLEAN emptyOK])
//

View File

@ -25,7 +25,7 @@
# ***** END LICENSE BLOCK *****
#%]
[% INCLUDE global/html_header.tmpl %]
[% INCLUDE global/html_header.tmpl js_files=['js/FormValidation.js'] %]
[% INCLUDE global/litmus_header.tmpl %]
<div id="page">

View File

@ -27,15 +27,28 @@
[% PROCESS global/selects.none.tmpl %]
<form name="search_results" method="get" action="search_results.cgi" onSubmit="if(this.summary.value=='-Summary-'){this.summary.value = '';}if(this.email.value=='-Submitted By-'){this.email.value = '';}">
<script type="text/javascript">
function init()
{
FormInit(document.forms['search_results'], document.location.search);
}
function checkSearchForm(f)
{
if ( ! checkNumber(f.limit,true)) {
return false;
}
if (f.summary.value=='-Summary-') {
f.summary.value = '';
}
if (f.email.value=='-Submitted By-') {
f.email.value = '';
}
}
</script>
<form name="search_results" method="get" action="search_results.cgi" onSubmit="return checkSearchForm(this);">
<!--# Add a row to order the results by each field. -->
<tr class="search">