Jquery验证与占位符Polyfill不兼容?[IE9错误]

Jquery验证与占位符Polyfill不兼容?[IE9错误],jquery,jquery-validate,placeholder,polyfills,Jquery,Jquery Validate,Placeholder,Polyfills,我目前正在将与结合使用,并且在使用Internet Explorer 9时遇到了一个令人沮丧的错误 如果我的type=“password”字段定义了非空的占位符属性,则我无法获得所需的字段验证来处理这些字段。一旦输入了值且占位符文本消失,剩余的验证工作正常 JS $('input').placeholder(); // init placeholder plugin signupFormValidator = $('form').validate(); // init validation

我目前正在将与结合使用,并且在使用Internet Explorer 9时遇到了一个令人沮丧的错误

如果我的
type=“password”
字段定义了非空的
占位符
属性,则我无法获得所需的字段验证来处理这些字段。一旦输入了值且占位符文本消失,剩余的验证工作正常

JS

$('input').placeholder(); // init placeholder plugin
signupFormValidator = $('form').validate(); // init validation
HTML

<form>
  <input class="required" type="text" name="test" id="test" placeholder="test"><br>
  <input class="required" type="password" name="password" id="password" placeholder="password"><br>
  <input class="required" type="password" name="confirm"  id="confirm"  placeholder="confirm"><br>
  <input type="submit">
</form>





编辑:此修复程序会在Firefox中引入错误。请看下面的评论


为了解决这个问题,我最终使用了一些我自己制作的相当粗糙的jQuery:

$('#password, #confirm').keyup(function() {
    var $input = $(this);
    if ($input.attr('type') === 'text') {
        if ($input.val().length > 0) {
            $input.attr('type', 'password');
        }
    } else if ($input.val() === "") {
        $input.attr('type', 'text');
    }
});
这样做的目的是将字段
type
设置为“text”而不是“password”,有效地解决了这个讨厌的占位符问题


小问题:开始在输入中输入文本时,密码的第一个字符会短暂显示为纯文本。

您是否找到了解决此问题的方法?不幸的是,没有干净的解决方案,但我最终使用了一些JS的解决方案。查看下面我的新答案。@creativetim仅供参考-刚刚发现我的黑客/修复程序在FF中被破坏。回到drawing board.FYI,刚刚发现这(可能)引入了一个bug(到目前为止只在Firefox中重现)。当快速键入密码字段时,游标有时会在单词的中间结束。我会发回任何进一步的发现/解决方案。