JSFiddle - React, Tailwind, and code Playground
HTML
<label for="city">* City </label>
<input type="text" name="city" id="city" placeholder="Enter City Name Here ." size="40" required="required" onblur="return cityCheck();"/>
<span id="error6"></span><br />
JavaScript
function cityCheck()
{
var city = document.getElementById('city').value;
if(city.trim()=== "" || city.lenth<2)
{
document.getElementById('error6').innerHTML = "Please enter your city ."; document.getElementById('city').focus();
document.getElementById('city').value = '';
return false;
}
else
{
document.getElementById('error6').innerHTML = "";
return true;
}
}