added more helper methods.

This commit is contained in:
DESKTOP-T0O5CDB\DESK-555BD
2024-01-22 11:09:01 -07:00
parent aad1655f2e
commit 175ce2be48
2 changed files with 7 additions and 2 deletions

View File

@@ -65,6 +65,11 @@
input = input.replace(decimalSeparator, "."); input = input.replace(decimalSeparator, ".");
return parseFloat(input); return parseFloat(input);
} }
function globalFloatToString(input) {
var decimalSeparator = "@numberFormat.NumberDecimalSeparator";
input = input.replace(".", decimalSeparator);
return input;
}
</script> </script>
@await RenderSectionAsync("Scripts", required: false) @await RenderSectionAsync("Scripts", required: false)
</head> </head>

View File

@@ -99,12 +99,12 @@ function getAndValidateGasRecordValues() {
} }
if (gasCostType != undefined && gasCostType == 'unit') { if (gasCostType != undefined && gasCostType == 'unit') {
var convertedGasCost = globalParseFloat(gasCost) * globalParseFloat(gasGallons); var convertedGasCost = globalParseFloat(gasCost) * globalParseFloat(gasGallons);
gasCost = convertedGasCost.toFixed(2).toString(); if (isNaN(convertedGasCost))
if (isNaN(gasCost))
{ {
hasError = true; hasError = true;
$("#gasRecordCost").addClass("is-invalid"); $("#gasRecordCost").addClass("is-invalid");
} else { } else {
gasCost = globalFloatToString(convertedGasCost.toFixed(2).toString());
$("#gasRecordCost").removeClass("is-invalid"); $("#gasRecordCost").removeClass("is-invalid");
} }
} }