JSFiddle - React, Tailwind, and code Playground
by Satpal Singh
HTML
<form id = "f">
First Name: <input type="text" name="input" id = "x" size="20" onblur="leave()" />
<br/>
Last Name: <input type="text" id = "y" size = "20" value = "enter your name here"/>
<input type="button" value = "Check!" onClick = "do1()"/>
</form>
JavaScript
function leave()
{
var x = document.getElementById("x");
if(x.value == "")
{
alert("please enter your name");
x.focus();
}
}
function do1()
{
var y = document.getElementById("y");
if (y.value == "enter your name here")
{
alert("enter your last name");
y.focus();
y.select();
}
}