0

Is there a way to tell live view to exclude certain fields from phx_change and use on blur event instead? For example when user types a long message in a form, I would like to avoid sending every keystroke to the server, but keep sending it for another_field. Is there a possibility to do the validation on blur for given form component?

<h2>Start a conversation</h2>

<%= f = form_for @changeset, "#",
  id: "conversation-form",
  phx_target: @myself,
  phx_change: "validate",
  phx_submit: "save" %>

  <%= label f, :message %>
  <%= textarea f, :message %>
  <%= error_tag f, :message %>

  <%= label f, :another_field %>
  <%= text_input f, :another_field %>
  <%= error_tag f, :another_field %>

  <%= submit "Send", phx_disable_with: "Sending..." %>
</form>
4

0 回答 0