This repository has been archived on 2024-10-29. You can view files and clone it, but cannot push or open issues or pull requests.
FunctionProject/scripts/execute-function/randomNumber_DOM.js

22 lines
990 B
JavaScript
Raw Normal View History

import { randomNumber } from '../functions/fonctions_principales/randomNumber_Function.js';
import { isEmptyValue } from '../functions/fonctions_annexes/isEmptyValue_Function.js';
import { formatNumberResult } from '../functions/fonctions_annexes/formatNumberResult_Function.js';
$(function () {
$("#randomNumberForm").submit((event) => {
event.preventDefault();
const minEntered = $('#minValue').val();
const maxEntered = $('#maxValue').val();
if(isEmptyValue(minEntered) || isEmptyValue(maxEntered)) {
$('.results').html(emptyMessageError);
}
else {
const result = randomNumber(minEntered, maxEntered);
if(result === messageError) {
$('.results').html(messageError);
} else {
$('.results').html("Nombre aléatoire compris entre " + minEntered + " inclus et " + maxEntered + " inclus : " + formatNumberResult(result));
}
}
});
});