4

Is there a way to turn the live validating of inputs in Zurb Foundation off, so the validation only happens when a field is actually left?

The docs point to the variable: live_validate, but setting it to false seems to have no effect. Also this actually never seems to be used by foundation.abide.js

Further it might be a good idea to set live validation field specific, instead of globally.

Any ideas?

zer00ne
  • 41,936
  • 6
  • 41
  • 68
mr.T
  • 351
  • 1
  • 4
  • 12
  • What Foundation version are you using? Would be nice to have the code that you are using to start abide. – Eduardo Jan 29 '14 at 16:19

1 Answers1

3

Looks like there is not a way to do that using live_validate. Indeed, this parameter is not even being used inside Abide.

A way to indirectly solve this problem it is using the timeout parameter. It defines, in milliseconds, how frequent the field is going to be checked for validation, it is a kind of polling made on the field. If you set a high timeout value, it will end up working as you want, i.e., the timeout will not expire and the field will be validated only when it loses its focus.

Therefore, something like the following code will be a workaround:

/* 100 seconds until verifying the field to be validated */
$(document).foundation({abide: { timeout: 100000, patterns: { xxx: /^...$/ } }});

As a side note, I've added the live_validate to the Abide code and proposed the pull request on Github. Hopefully it will be merged. If you want use it now, use Abide from my fork.

Edit: My pull request was merged on the master. Therefore, you can now have the live_validate flag officially from zurb:master

Eduardo
  • 4,282
  • 2
  • 49
  • 63
  • Thanx a lot Eduardo! This will probably ease a lot of headaches. We now actually decided to use 'backbone.validation' in combination with 'backbone.stickit', which gives us some more options as well. – mr.T Feb 03 '14 at 13:10
  • You are welcome, @mr.T. Nice, I did not know about backbone validation. Cheers! – Eduardo Feb 03 '14 at 13:38
  • 2
    Can't seem to make this work. Not only does abide.js ignore the live_update = false attribute, but also the timeout duration. I'm not sure why this module is so messy. – cbmtrx Dec 04 '14 at 16:21