jQuery验证引擎无法处理动态生成的字段

时间:2014-06-16 11:29:45

标签: jquery jquery-validation-engine

我创建了一个网页,并使用jQuery验证引擎来验证页面。验证引擎在页面上的其他字段中工作。但是通过javascript加载/生成的字段很少。

此字段不会运行验证。

以下是我将验证引擎附加到表单

的方法
$("#request123").validationEngine('attach', {
        onValidationComplete: function(form, statusvalidate){
            if(statusvalidate)
            {
                searchSubmit();
            }
        }  
    });

我希望这些验证能够在网页元素模糊的情况下运行,所以我使用了

$.validationEngine= {fieldIdCounter: 0,defaults:{

        // Name of the event triggering field validation
        validationEventTrigger: "blur",
        // Automatically scroll viewport to the first error
        scroll: true,
        // Focus on the first input
        focusFirstField:true,
        // Opening box position, possible locations are: topLeft,
        // topRight, bottomLeft, centerRight, bottomRight
        promptPosition: "topLeft",
        bindMethod:"bind",
        // internal, automatically set to true when it parse a _ajax rule
        inlineAjax: false,
        // if set to true, the form data is sent asynchronously via ajax to the form.action url (get)
        ajaxFormValidation: false,
        // The url to send the submit ajax validation (default to action)
        ajaxFormValidationURL: false,
        // HTTP method used for ajax validation
        ajaxFormValidationMethod: 'get',
        // Ajax form validation callback method: boolean onComplete(form, status, errors, options)
        // retuns false if the form.submit event needs to be canceled.
        onAjaxFormComplete: $.noop,
        // called right before the ajax call, may return false to cancel
        onBeforeAjaxFormValidation: $.noop,
        // Stops form from submitting and execute function assiciated with it
        onValidationComplete: false,

        // Used when you have a form fields too close and the errors messages are on top of other disturbing viewing messages
        doNotShowAllErrosOnSubmit: false,
        // Object where you store custom messages to override the default error messages
        custom_error_messages:{},
        // true if you want to vind the input fields
        binded: true,
        // set to true, when the prompt arrow needs to be displayed
        showArrow: true,
        // did one of the validation fail ? kept global to stop further ajax validations
        isError: false,
        // Limit how many displayed errors a field can have
        maxErrorsPerField: false,

        // Caches field validation status, typically only bad status are created.
        // the array is used during ajax form validation to detect issues early and prevent an expensive submit
        ajaxValidCache: {},
        // Auto update prompt position after window resize
        autoPositionUpdate: false,

        InvalidFields: [],
        onFieldSuccess: false,
        onFieldFailure: false,
        onFormSuccess: false,
        onFormFailure: false,
        addSuccessCssClassToField: false,
        addFailureCssClassToField: false,

        // Auto-hide prompt
        autoHidePrompt: true,
        // Delay before auto-hide
        autoHideDelay: 3000,
        // Fade out duration while hiding the validations
        fadeDuration: 0.1,
    // Use Prettify select library
    prettySelect: false,
    // Custom ID uses prefix
    usePrefix: "",
    // Custom ID uses suffix
    useSuffix: "",
    // Only show one message per error prompt
    showOneMessage: false
    }};
    $(function(){$.validationEngine.defaults.promptPosition = methods.isRTL()?'topRight':"topLeft"});
})(jQuery);

此外,我已经分离并附加了我的addrow方法中的valdation引擎,这会导致页面的DOM结构发生变化

$("#request123").validationEngine('detach');
    $("#request123").validationEngine('attach',{onValidationComplete:function(form, statusvalidate){
        if(statusvalidate)
        {
            searchSubmit();
        }
    }  });

可能是什么原因?什么是解决方案?

0 个答案:

没有答案