鍍金池/ 問答/HTML/ 請教一個關(guān)于validform 表單驗證的問題

請教一個關(guān)于validform 表單驗證的問題

關(guān)于自定義驗證錯誤信息以彈出框的方式顯示

相關(guān)代碼:
<form id="addaddress-form">
    <div class="m-cell">
        <div class="cell-item">
            <div class="cell-left">收件人:</div>
            <div class="cell-right">
                <input type="text" name="uname" class="cell-input" datatype="*" placeholder="請輸入收件人姓名" >
            </div>
        </div>
        <div class="cell-item">
            <div class="cell-left">手機號碼:</div>
            <div class="cell-right">
                <input type="number" name="uphone" pattern="[0-9]*" datatype="*" class="cell-input" placeholder="請輸入手機號" 
                />
            </div>
        </div>
        <div class="cell-item">
            <div class="cell-left">收件地址:</div>
            <div class="cell-right">
                <input type="text" name="uaddress" class="cell-input cell-arrow" datatype="*" placeholder="省/市/區(qū)">
            </div>
        </div>
        <div class="cell-item">
            <div class="cell-left">詳細(xì)地址:</div>
            <div class="cell-right">
                <input type="text" name="udetailedaddress" class="cell-input" datatype="*" placeholder="請輸入詳細(xì)收貨地址">
            </div>
        </div>
    </div>
    <div class="pd20">
        <button type="button" class="btn-block btn-fcx j-save">保存配送地址</a>
    </div>
</form>
$(function () {
    // var dialog = window.YDUI.dialog;
    var addaddressForm = $('#addaddress-form').Validform({
        btnSubmit: '.j-save',
        tiptype: function (msg, o, cssctl) {
            if (o.type !== 2) {
                //dialog.toast(msg, 'error', 1000, function () {});
            } else {
                return false;
            }
        },
        tipSweep: true,
        showAllError: false,
        beforeSubmit: function (curform) {
            console.log(curform)
            return false;
        }
    });
});

問題在于,提示了錯誤信息后,當(dāng)前驗證的那個input框會自動獲取焦點。 我想取消掉,驗證不通過的不自動獲取到焦點上。

拜托!-_- !找了文檔也沒有找到相應(yīng)的參數(shù)。!

回答
編輯回答
澐染

驗証完後調(diào)用 document.activeElement.blur();

2017年4月4日 06:48