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.
Asked
Active
Viewed 7,704 times
3 Answers
22
You can check for the existence of $.validator
:
if ($.validator) {
// $.validator is defined
}

Konstantin Dinev
- 34,219
- 14
- 75
- 100
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.
}

Matt
- 74,352
- 26
- 153
- 180
0
This works with ValidationEngine 2.6.2:
if (typeof jQuery.fn.validationEngine === "function") {
// It's loaded
} else {
// It's not.
}

bart
- 14,958
- 21
- 75
- 105