JSFiddle - React, Tailwind, and code Playground

by lrvick

HTML

<input id='input' type='text'>

JavaScript

$("#input").keydown(function(event) {
    if (event.keyCode == 13) {
        event.preventDefault();
        var value = $("#input").val();
        if (value != 'foo') {
            alert('Only foo is allowed!')
        } else {
            alert('Good girl!')
            //do your ajax form submit here.
        }
    }
})