JSFiddle - React, Tailwind, and code Playground

by refhat

HTML

<form>
    <input type="text" class="required"><br>
<input type="text" class="required"><br>
<input type="text" class="required"><br>
    <input type="submit" value ="GO" onsubmit ="return validatemyForm();"></form>

JavaScript

function validatemyForm() {
        var ok = true;
        $('.required').each(function() {
            if($(this).val() == "" || $(this).val().replace(/\s/g, '').length == 0)
            {
                $(this).insertAfter('<span>This is a Required Field</span>');
                ok = false;
            }
            else {
                $(this).remove();
            }
        })
        return ok;
    }

$('form').submit(validatemyForm);