JSFiddle - React, Tailwind, and code Playground

by mayanksaxena19

HTML

<div >Type following values and hit enter <ol> 
    <li>test</li>
</ol></div>
<input type="text" id="name" autocomplete="off"></input>
<div id='alertmsg'></div>

CSS

#alertmsg {
    color : red;
    width : 200px;
    height : 100px;
}

JavaScript

$(function () {
    function updateName() {
        var message = "";
        if ($('#name').val() == 'test') message = "Name already exists";
        $('#alertmsg').text(message);
    }
    $('#name').bind("keypress", function (e) {
        if (e.keyCode == 13) {
            e.preventDefault();
            updateName();
            return false;
        }
    });
});