placeholder issue with jQuery Validate

前端 未结 9 736
时光说笑
时光说笑 2020-12-31 19:10

I noticed today that we have an issue with jquery Validate when used in conjunction with placeholder text.

Example:

&
9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-31 19:48

    $("form").validate();
        $(function () {
                    $.each($.validator.methods, function (key, value) {
                    $.validator.methods[key] = function () {
                    var el = $(arguments[1]);
                    if (el.is('[placeholder]') && arguments[0] == el.attr('placeholder'))
                        arguments[0] = '';
                        return value.apply(this, arguments);
                        };
                     });
          });
    

提交回复
热议问题