1 2 3 4 5 6 7 8 9 $( 'input#message' ).keydown( function (key) { if (key.keyCode = = 13 & & $( '#name' ).val() ! = '' & & $( '#message' ).val() ! = '' ){ socket.emit( 'message' ,{ name :$( '#name' ).val(), message:$( '#message' ).val(), date: new Date ().toUTCString() ...