Answer the question
In order to leave comments, you need to log in
How to prevent HTML input on pressing ENTER?
When I click on an empty text field -> ENTER, the following markup is inserted
, but I need this markup to be absent and generally on pressing ENTER, if the field is empty, then do nothing with it,
I tried to do it like this, but still there is a "backlash" carriages
<div><br></div><div><br></div>
$(".msg-block").keyup(function(event) {
if (event.keyCode === 13 && $('.emoji-wysiwyg-editor').text() === '' ) {
$('.emoji-wysiwyg-editor').html('')
}
});
Answer the question
In order to leave comments, you need to log in
To prevent the click from working - you need to add a call to `event.preventDefault()`
In my opinion, it's a bad idea to use blocks for text input. Better use textarea + autosize.
This is a plugin that automatically changes the height of the text field depending on the number of lines:
https://www.jacklmoore.com/autosize
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question