jQuery 检查虚假条目

发布于 2024-11-18 16:57:16 字数 160 浏览 3 评论 0原文

我有一个用户必须填写的表单。有几个字段需要至少 50 个字符。我需要阻止用户输入超过 50 个句号或其他字母/数字。我已经成功地捕获了多个句号的输入,但是有人知道 JavaScript/jQuery 正则表达式可以按顺序查找 5 个或更多的任何字符吗?

预先非常感谢,

杰森

I have a form which the user has to fill in. A couple of fields are required to have a minimum of 50 characters. I need to stop the user from entering i.e. over 50 full stops, or another letter/number. I've managed to trap the entry of multiple full stops but does anyone know of a JavaScript/jQuery regular expression to find maybe 5 or more of any character in sequence?

Many thanks in advance,

Jason

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不打扰别人 2024-11-25 16:57:16

试试这个:

str.match(/(.)\1{5,}/);

这意味着:匹配任何字符,将其放入捕获组 1 中,并重复匹配该组 5 次或更多次。

Try this:

str.match(/(.)\1{5,}/);

This means: match any character, place it in a capturing group 1, and match this group repeating 5 or more times.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文