JSFiddle - React, Tailwind, and code Playground

by Luis Manuel

HTML

<input id="authorities" name="authorities" type="text">
<input id="team_authority_emails" name="team[authority_emails]" type="hidden" value="{[email protected],[email protected]}">

JavaScript

$('#authorities').bind("keyup", function(e) {
    var value = $(this).val();
    if(e.which == 13 && value != ''){ //And other validations you may want
        var value = $(this).val();
        $('#team_authority_emails').val(function(i,val) {
            return val + (val ? ', ' : '') + value;
        });
        $(this).val('');
        return false;
    }
});