function bereken() {
input1 = document.getElementById('input1').value;
input2 = document.getElementById('input2').value;
input1Valid = Number.isInteger(document.getElementById('input1'));
input2Valid = Number.isInteger(document.getElementById('input2'));
if (Number.isInteger(input1) && Number.isInteger(input2)) {
alert('De getallen zijn allebei hele getallen')
}
}
<!DOCTYPE html>
<html>
<head>
<script src='code.js'></script>
</head>
<body>
<center>
<h1>GGD calculator</h1>
<p>Reken de Grote Gemene Deler uit van <input type='number' id='input1'> en <input type='number' id='input2'>.</p>
<br>
<input type='button' value='Bereken!' onClick='bereken()'>
</center>
</body>
</html>
I was practising JavaScript and I came across this issue, can anybody help you?
I want it to alert my message when both numbers entered are integers, why is this not working?
Aucun commentaire:
Enregistrer un commentaire