Z
Z
Zubastik_12017-10-14 21:22:11
Vue.js
Zubastik_1, 2017-10-14 21:22:11

How to submit a form with an enter condition that the field is filled (in Vue.js)?

Here is my code. I just don't know how to make the send conditional that the textarea field is filled?

<textarea  v-on:keyup.enter="newMessage" id="chat_msg" placeholder="" v-model="input"></textarea>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Velko, 2017-10-14
@Zubastik_1

<textarea
  @keypress.enter.prevent="input.length && newMessage()"
  id="chat_msg"
  placeholder=""
  v-model="input"
>
</textarea>

live example .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question