使用元素上的元数据通过 jQuery 验证插件将其验证为信用卡

发布于 2025-01-04 01:27:47 字数 252 浏览 4 评论 0原文

我可以将元数据添加到输入的 html 中,以便 jQuery 验证插件将其验证为信用卡号吗?如何指定所有信用卡类型都可接受?

(类似于包含“数字”类来验证仅输入数字。)

我已经尝试过这个(在黑暗中拍摄):

<input class="title" creditcardtypes="all" creditcard="true" name="cc-number" maxlength="16">

Can I add metadata to an input's html so that the jQuery validation plugin will validate it as a credit card number? How do I specify that all credit card types are acceptable?

(Analogous to including the class "digits" to validate that only digits are input.)

I have tried this (shot in the dark):

<input class="title" creditcardtypes="all" creditcard="true" name="cc-number" maxlength="16">

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

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

发布评论

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

评论(1

薄荷梦 2025-01-11 01:27:47

您可以在 jquery 验证插件中使用信用卡规则而不是数字

    rules:{
        input_name:{required:true,creditcard:true}
    },

you can use the creditcard rule in jquery validation plugin rather than digits

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