casperin / nod

Plugin that gives you frontend validation for forms.
http://casperin.github.io/nod/
381 stars 137 forks source link

Validation issues on mobile (currently happens on `focusout` instead of `keydown`) #102

Closed bkrall closed 9 years ago

bkrall commented 9 years ago

It looks like this issue is similar to mine: https://github.com/casperin/nod/issues/77, but not quite exactly the same.

I have a reset password form, and on mobile the "Submit" button doesn't become active until you focousout of the input. On mobile, this is a bit more cumbersome than just clicking out of the input, instead you have to close the keyboard or manually tap out of it.

Is it possible to validate the form on keydown rather than on focusout? Thanks for your help.

casperin commented 9 years ago

Hmmm... to be honest I have not done a single test on mobile (it somehow never crossed my mind), but good that you are :)

You can see the event triggers here: https://github.com/casperin/nod/blob/master/nod.js#L534. I'm a little surprised that input doesn't trigger the same way keydown does. You can add your own events too (see https://github.com/casperin/nod#triggerevents), so adding "keydown" wouldn't be hard. Would you mind letting me know which setup works for you? Then I'll try to update the library so it hits as "widely" as possible. :)

bkrall commented 9 years ago

Ah, it looks like we're stuck on v.1 so we'll need to upgrade before we try out triggerEvents. I know v.2 isn't backwards compatible, is there a good guide (or any tips) to going to the newest version?

casperin commented 9 years ago

No, there isn't really. Generally (from memory) it goes something like

From:

nod('.foo', 'presence', 'some error msg');

To:

myNod.add({
    selector: '.foo',
    validate: 'presence',
    errorMessage: 'some error msg'
});

But it was a very substantial rewrite. I highly suggest that you upgrade though. It's infinitely more stable, and easier to configure. :)

casperin commented 9 years ago

I'll close the issue for now. If you still have problems with mobile, the please open it again.