question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add blur event for validation libraries

See original GitHub issue

I’m submitting a … (check one with “x”)

[ ] Bug report => search github for a similar issue or PR before submitting
[x] Feature request
[ ] Other, please describe

A PR (#22) was opened a while back adding the blur event, and you said you couldn’t see a use case and that it would mean other events would need adding. In our application, there is a use case for this, and that is when using the vuelidate where validations can be triggered when a field is blurred. Currently I cannot apply this with vue-flatpickr due to this event not being registered/emit.

I don’t disagree with your statement that it may make sense then to allow other events to be added such as keyboard events, however since Vue 2.4 it is possible to simply bind all listeners provided to a component via the $listeners property.

This would allow the developer to decide which listener they wish to bind rather than vue-flatpickr having to pick and choose. I don’t know the all of the code, but at a quick glance it would as simple as changing the template of the component to

<input type="text" data-input v-on="inputListeners">

and adding a computed property

inputListeners() {
  let vm = this;
  return Object.assign({},
    vm.$listeners,
    {
      input: vm.onInput,
    }
  );
}

With this change, I would be able to do something like

<flat-pickr
  v-model="model"
  :config="config"
  @blur="onBlur"
  @keydown="onKeydown">

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pareeohnoscommented, Sep 4, 2018

Sorry for the delay, just got round to testing and it works perfectly. Thanks for the quick turn around

1reaction
pareeohnoscommented, Aug 8, 2018

awesome thank you!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Form validation on blur - javascript - Stack Overflow
I have 5 input fields and I want them to validate on blur, and show either an error or success message, but through...
Read more >
Simple custom form validation on blur event with Svelte
Easy way to add client-side custom form validation using Svelte and blur event. It helps to makes sure that submitted data matches the...
Read more >
input field validation on blur event - Oracle Communities
HI, I need input field validation on blur event, JSF2.0 custom validation are working fine,but i need them on change tab event.
Read more >
How do I validate form elements via onblur events?
I'm not sure I understand - which JS library are you using for validation? Ie what is making that validate() method available to...
Read more >
Validating SharePoint form fields on blur event
Place your <script> tags in that section. First put the reference to the jQuery library (see Step 1) and then add your additional...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found