Random Phone Number
Why force users to do the hard work of typing their 8-digit phone number when you can just randomly guess it for them? With only 40,000,000 possibilities, they're bound to hit "Yes" eventually!
Live Preview
Please confirm if the number below is correct.
Generated Number
61234567
Is this your phone number?
Source Code
random_phone.html
<h1>Enter your phone number</h1>
<label for="phone_random">Phone Number: </label>
<div name="phone_random" id="phone_number_box">61234567</div>
<p>Is this your phone number?</p>
<button onclick="yipee()">Yes</button>
<button onclick="randomNewNumber()">No</button>
<p id="res"></p>
<script>
const box = document.getElementById('phone_number_box');
const res = document.getElementById('res');
let currentNumber = 61234567;
function randomNewNumber() {
currentNumber = Math.floor(Math.random() * (99999999 - 60000000 + 1)) + 60000000;
box.innerText = currentNumber;
}
function yipee() {
res.innerText = `Confirmed! Number is ${currentNumber}`;
}
window.addEventListener('load', randomNewNumber);
</script>