17 lines
714 B
JavaScript
17 lines
714 B
JavaScript
import { convertDistance } from '../functions/fonctions_principales/convertDistance_Function.js';
|
|
|
|
$(function () {
|
|
$("#convertDistanceForm").submit((event) => {
|
|
event.preventDefault();
|
|
let firstValue = $('#firstValue').val();
|
|
const unitFirstValue = $("#firstValueUnit option:selected").text();
|
|
const secondValue = $("#secondValue option:selected").text();
|
|
if(isEmptyValue(firstValue) || isEmptyValue(secondValue)) {
|
|
$('.results').html(emptyMessageError);
|
|
}
|
|
else {
|
|
firstValue = parseFloat(firstValue.replace(/\s/g,''));
|
|
$('.results').html(convertDistance(firstValue, unitFirstValue, secondValue));
|
|
}
|
|
});
|
|
}); |