Foundation 4:Unable to overwrite its regular expression to validate password

六眼飞鱼酱① 提交于 2019-12-06 21:37:32

Replacing pattern called password does the trick. Change

<script>
  $(document).foundation();
</script>

at the bottom of index.html to the following code:

<script>
  $(document)
    .foundation()
    .foundation('abide', {
      patterns: {
        password: /^\w{3,14}$/,
      }
    });
</script>

Note that the regex you provided (^[a-zA-Z]\w{3,14}$) should be written as /^[a-zA-Z]\w{3,14}$/ in JavaScript.

Update the value before running foundation:

<script>
Foundation.libs.abide.settings.patterns.password = /^\w{3,14}$/;
$(document).foundation();
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!