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.
How to check if jQuery Validation Engine is loaded?
Asked Answered
You can check for the existence of $.validator
:
if ($.validator) {
// $.validator is defined
}
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.
}
This works with ValidationEngine 2.6.2:
if (typeof jQuery.fn.validationEngine === "function") {
// It's loaded
} else {
// It's not.
}
© 2022 - 2024 — McMap. All rights reserved.