How to check if jQuery Validation Engine is loaded?
Asked Answered
W

3

9

I'm trying to use this validator: http://posabsolute.github.com/jQuery-Validation-Engine/ I load it just when a page has a form. But I have several pages with 2 form, both are loading with ajax. So, I need to check for each form before load: is the Validator loaded or not. how can I to check this? Thanks.

Wreckage answered 3/3, 2013 at 12:27 Comment(0)
C
23

You can check for the existence of $.validator:

if ($.validator) {
    // $.validator is defined
}
Cruet answered 3/3, 2013 at 12:31 Comment(0)
U
0

The plugin adds a validationPlugin function to jQuery.fn, so simply check whether it exists or not;

if (typeof jQuery.fn.validationPlugin === "function") {
    // It's loaded
} else {
    // It's not.
}
Ufo answered 3/3, 2013 at 12:31 Comment(0)
M
0

This works with ValidationEngine 2.6.2:

if (typeof jQuery.fn.validationEngine === "function") {
    // It's loaded
} else {
    // It's not.
}
Marcusmarcy answered 5/12, 2015 at 22:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.