JSFiddle - React, Tailwind, and code Playground

by bitstarr

HTML

<div class="first_name"><label class="optional" for="firstName">Vorname</label>
<input type="text" value="" id="firstName" name="firstName"></div>
<form action="#">

<div class="email"><label class="optional" for="email">E-Mail</label>
<input type="text" value="" id="email" name="email"></div>

<div class="customerId"><label class="optional" for="customerId">Kundennummer</label>
<input type="text" value="" id="customerId" name="customerId"></div>
    
    <button>Hi</button>
</form>

CSS

div {margin: 0 0 1em 0}
label {display: block}

JavaScript

$(function(){
    $("#customerId").blur(function() {
        var elements = '#firstName,#email';
        if ($(this).val() != '') {
            $(elements).attr('disabled','disabled');
        }
        else {
             $(elements).removeAttr('disabled');
        }
    });
});