bug 7817: service offering page - apply validateInteger().

This commit is contained in:
Jessica Wang 2011-01-21 10:20:39 -08:00
parent b0d390aef1
commit b47d843cc1
2 changed files with 6 additions and 5 deletions

View File

@ -1465,13 +1465,14 @@ function validateDropDownBox(label, field, errMsgField, appendErrMsg) {
}
function validateInteger(label, field, errMsgField, min, max, isOptional) {
validateNumber(label, field, errMsgField, min, max, isOptional, "integer");
return validateNumber(label, field, errMsgField, min, max, isOptional, "integer");
}
function validateNumber(label, field, errMsgField, min, max, isOptional, type) {
var isValid = true;
var errMsg = "";
var value = field.val();
var value = field.val();
if (value != null && value.length != 0) {
if(isNaN(value)) {
errMsg = label + " must be a number";

View File

@ -91,9 +91,9 @@ function initAddServiceOfferingDialog() {
var isValid = true;
isValid &= validateString("Name", thisDialog.find("#add_service_name"), thisDialog.find("#add_service_name_errormsg"));
isValid &= validateString("Display Text", thisDialog.find("#add_service_display"), thisDialog.find("#add_service_display_errormsg"));
isValid &= validateNumber("# of CPU Core", thisDialog.find("#add_service_cpucore"), thisDialog.find("#add_service_cpucore_errormsg"), 1, 1000);
isValid &= validateNumber("CPU", thisDialog.find("#add_service_cpu"), thisDialog.find("#add_service_cpu_errormsg"), 100, 100000);
isValid &= validateNumber("Memory", thisDialog.find("#add_service_memory"), thisDialog.find("#add_service_memory_errormsg"), 64, 1000000);
isValid &= validateInteger("# of CPU Core", thisDialog.find("#add_service_cpucore"), thisDialog.find("#add_service_cpucore_errormsg"), 1, 1000);
isValid &= validateInteger("CPU", thisDialog.find("#add_service_cpu"), thisDialog.find("#add_service_cpu_errormsg"), 100, 100000);
isValid &= validateInteger("Memory", thisDialog.find("#add_service_memory"), thisDialog.find("#add_service_memory_errormsg"), 64, 1000000);
isValid &= validateString("Tags", thisDialog.find("#add_service_tags"), thisDialog.find("#add_service_tags_errormsg"), true); //optional
if (!isValid)
return;