JSFiddle - React, Tailwind, and code Playground

by Ehsan Sajjad

HTML

<input type="text" placeholder="Contact Name" class="required" />
<input type="submit" value="Submit" onclick="return CheckRequired();">

JavaScript

function CheckRequired() {
    $(".required").each( function() {
        var check = $(this).text();
    
        if(check == '') {
            alert("Cannot be blank");
        }
    });
}