JSFiddle - React, Tailwind, and code Playground
by Sourav Chatterjee
HTML
<div id="formA">
<form method="post" onSubmit="return validate();">
<label for="name">Name</label>
<input type="text" id="name" placeholder="Enter Name">
<br>
<label for="location">Location</label>
<input type="text" name="location" placeholder="Enter Location">
<br>
<input type="submit">
</form>
</div>
JavaScript
function validate(){
if(document.getElementByID("name").value.length===0){
alert('Enter a Name');
document.getElementById("name").focus();
return false;
}
}