JSFiddle - React, Tailwind, and code Playground
by Asifuzzaman
HTML
<body >
<form id="form1">
<input id="LastName" class="required" name="LastName" type="text" placeholder="Last Name"
required/>
<input id="LastName" class="required"name="LastName" type="text" placeholder="first Name"
required/>
<input id="password" class="required" name="password" type="password" placeholder="password"
required/>
<input type="submit" id="sub" value="save">
</form>
</body>
JavaScript
$('#sub').click(function(e){
e.preventDefault()
$('.required').each(function() {
if($(this).val() == '') {
$(this).css('background-color' , '#FF0000');
$(this).attr("placeholder", "Required");
}
});
});