JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="txtComments" name="txtComments" placeholder="Enter your comments"
style="width: 500px; height: 50px;" />

JavaScript

$(document).ready(function () {
    $("#txtComments").keypress(function (e) {
        var comments = "";
        var code = e.keyCode ? e.keyCode : e.which;
        if (code == 13) {
            e.preventDefault();
            comments = $("#txtComments").val();
            var request = $.ajax({
                url: "/Home/SaveCommentsData",
                type: "POST",
                data: {
                    'CommentEntered': comments
                },
                dataType: "json",
                success: function (data, textStatus) {
                    if (textStatus) {
                        $('#enteredComments').append('<span>' + comments + '</span>');
                        alert("Comment Saved");
                    }

                },
                error: function (textstatus) {

                    alert(textstatus);
                }
            });
        }

    });
});