javascriptvalidationzurb-foundationabide

How to turn Zurb Foundation Abide live validation off?


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?


Solution

  • 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