convertDistance input cleaner

This commit is contained in:
Divlo
2019-08-29 23:35:40 +02:00
parent 1a9efd50e6
commit 43b337238e
3 changed files with 27 additions and 9 deletions

View File

@ -97,19 +97,17 @@ $(function () {
$("#submitConvertDistance").click(function()
{
let firstValueEntered = $('#firstValue').val();
let secondValueEntered = $("#secondValue option:selected").text();
let firstValue = $('#firstValue').val();
let unitFirstValue = $("#firstValueUnit option:selected").text();
let secondValue = $("#secondValue option:selected").text();
if(isEmptyValue(firstValueEntered) || isEmptyValue(secondValueEntered))
if(isEmptyValue(firstValue) || isEmptyValue(secondValue))
{
$('.results').html(emptyMessageError);
}
else
{
let firstValue = parseFloat(firstValueEntered.slice(0, firstValueEntered.length - 2));;
let unitFirstValue = firstValueEntered.slice(firstValueEntered.length - 2);
let result = convertDistance(firstValue, unitFirstValue, secondValueEntered);
let result = convertDistance(parseFloat(firstValue), unitFirstValue, secondValue);
if(result === messageError)
{
$('.results').html(messageError);