基础 4:无法覆盖其正则表达式来验证密码 [英] Foundation 4:Unable to overwrite its regular expression to validate password

查看:29
本文介绍了基础 4:无法覆盖其正则表达式来验证密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想覆盖由foundation(zurb)提供的密码模式,但它不能识别我被覆盖的正则表达式并根据其默认表达式生成错误.默认情况下,foundation 提供的密码验证是必须至少为 8 个字符,其中包含 1 个大写字母、1 个数字和 1 个特殊字符".为此,我使用了以下内容:

1)

<脚本>$(文件).基础().foundation('遵守', {模式:{新:^[a-zA-Z]\w{3,14}$,}});</script></head><身体><form class="custom" data-abide><div class="row"><div class="large-12 列"><label>密码<small>必需</small></label><input type="password" pattern="new" required ><small class="error" data-error-message="">验证错误.</small>

</表单>

2)

</表单>

3)输入标签中直接使用的模式:

但所有这些都不起作用.请建议我解决我的问题.

您可以找到示例程序 - 这里

解决方案

替换名为 password 的模式可以解决问题.改变

index.html底部添加如下代码:

请注意,您提供的正则表达式 (^[a-zA-Z]\w{3,14}$) 应写为 /^[a-zA-Z]\w{3,14}$/ 在 JavaScript 中.

I want to overwrite password pattern provided by foundation(zurb) but its not identifying my overwritten regular expression and generated error according to its by default expression. By default,passwords validation provided by foundation is "must be at least 8 characters with 1 capital letter, 1 number, and one special character". For that I have used following:

1)

<head>
<script>
$(document)
  .foundation()
  .foundation('abide', {
    patterns: {
      new: ^[a-zA-Z]\w{3,14}$,
       }
  });
 </script></head>
<body>
<form class="custom" data-abide>
<div class="row">
    <div class="large-12 columns">
        <label>Password <small>required</small></label>
            <input type="password" pattern="new" required >
                <small class="error" data-error-message="">validation error.</small>
    </div>
</div>

</form>
</body>

2)

<form class="custom" data-abide="">
</form>

3)Directly used pattern in input tag:

<input type="password" pattern="^[a-zA-Z]\w{3,14}$" required >

But all these are not working.Please suggest me something to resolve my problem.

You can find the sample program - here

解决方案

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.

这篇关于基础 4:无法覆盖其正则表达式来验证密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆