JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="regkey" value="12345-67890-15975-14"/>
<button id="btn1">Validate</button>

JavaScript

$('#btn1').click(function(){
    var regkey = $('#regkey').val();
    var length = regkey.length;
    if (length != 20) {
         alert(length + " characters does not meet the requirements!");   
    } else {
        alert("The length is correct!");
    }
});