JSFiddle - React, Tailwind, and code Playground
HTML
<p style="display: inline-block; width: 40%; max-width: 200px;">Your Name:</p>
<input type="text" id="formname" name="formname" size="25" value="Freddy the Grocer" onclick="this.value='';" onblur="if(this.value=''){setdftvalue();})" required />
JavaScript
var dftvalue = ['Freddy the Grocer', 'Jack the Fiddler', 'Cane the Sheep Herder', 'Arnold the Fish Monger', 'Luke the Car Salesman', 'Josh the Tailor', 'Carol the Baker', 'Tiara the Nacho Vendor', 'example@email.com', 'Your message here.'];
var logused = new Array(); //create new array to log the used indexs
function setdftvalue() {
var newval = dftvalue[Math.floor(Math.random() * 7)];
if (logused.indexOf(newval) == -1) {
this.value=newval;
logused.push(newval);
console.log(logused);
} else if (logused.indexOf(newval) >= 0) {
if (logused.length == 8) {
for (i=0; i<=8; i++){
logused.pop();
}
} else {
setdftvalue();
}
}
}
document.getElementById('formname').onblur=setdftvalue;