$('#beginning, #ending').change(function() { generateNickname(); }); $('#input input').keyup(function(event){ if(event.keyCode == 13) { event.preventDefault(); } }); $(function() { generateNickname(); }); $('#copy').click(function() { $('#nickname').select(); }); $('#nickname').click(function() { $('#nickname').select(); }); $('#generate').click(function() { generateNickname(); }); function generateNickname() { var beginning = $('#beginning').val(); var ending = $('#ending').val(); $.ajax( { url: "/tools/generators/nickname_functions", cache: false, dataType: 'text', data: { beginning: beginning, ending: ending }, beforeSend: function() { $('#generate').button('loading'); }, success: function(data) { if(data !== "MySQL Error") { $('#nickname').val(data); $('#history').append(`