0

posAbsolute の jQuery 検証エンジンを使用していますが、解決策がわからないという問題に遭遇しました。検証エンジン プラグインでは、デフォルトで各フィールドが onBlur を検証します。私が持っているシナリオは、送信をクリックしてフォームが検証される前に、少なくとも4文字を入力する必要があるパスワード入力フィールドです。現在、4 文字未満を入力してクリックすると、入力フィールドの上にエラー div が表示されますが、ユーザーが戻ってきて少なくとも 4 文字を入力したときにエラー div を非表示にし、それ以外の場合はそのままにしておきます。

これが私のコードです:

<div class="register-form span5">       
<form method="post" form id="formID" class="formular form-horizontal" action="/account/registerguest">
<div class="row-fluid">
<fieldset class="span4">    
<label for="password">Password:</label> 
<input data-validation-engine="validate[required,custom[password]]" placeholder="Password" type="password" name="password" id="password" value="" />
</fieldset> 
</div>
</form>
</div>

そしてjquery:

(function($){
$.fn.validationEngineLanguage = function(){
};
$.validationEngineLanguage = {
    newLang: function(){
        $.validationEngineLanguage.allRules = {
            "required": { 
                "regex": "none",
                // "alertText": "* This field is required",                  
            },                    

            "password": {
                "regex": /(?=^.{4,}$)/,
                "alertText": "*Enter at least 4 characters"
            },             

        };

    }
};

$.validationEngineLanguage.newLang();    
})(jQuery);

    $("#formID").validationEngine();

function checkHELLO(field, rules, i, options){
    if (field.val() != "HELLO") {
        // this allows to use i18 for the error msgs
        return options.allrules;
    }
}   

そしてもちろん検証エンジン: https://github.com/posabsolute/jQuery-Validation-Engine

これに関して何か助けていただければ幸いです。十分な情報を提供できたことを願っています。これまでのところ、このプラグインの onBlur 検証を onKeyup に置き換えるという問題はどこにも見つかりませんでした。

4

1 に答える 1

0

もう少し突っ込んだ後、私は解決策を見つけました。plugin.js ファイルの「blur」を「keyup」に置き換えます。

// リーク グローバル オプション $.validationEngine= {fieldIdCounter: 0,defaults:{

    // Name of the event triggering field validation
    validationEventTrigger: "keyup",
    // Automatically scroll viewport to the first error
    scroll: false,
    // Focus on the first input
    focusFirstField:true,
    // Show prompts, set to false to disable prompts
    showPrompts: true,
于 2013-05-22T10:13:25.347 に答える