我们可以只使用html模式属性匹配一个确切的字符串吗? [英] Can we match an exact string using html pattern attribute only?

查看:84
本文介绍了我们可以只使用html模式属性匹配一个确切的字符串吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们解决问题,因为我允许在我的网站上开放注册(任何人都可以打开注册页面),但我只想那些能够继续拥有特定代码的人(如CDCode)。这是一种形式,我想在表格提交上检查。

Lets get to the problem as I allow open registration on my website(any one can open registration page) but I want only those people able to proceed who have a specific code (like "CDCode"). This is in a form and I want to check it on form Submit.

我知道可以使用onfocusout但javascript可以被禁用,因此不是一个完美的解决方案。

I know it is possible with onfocusout but javascript can be disabled so not a perfect solution.

我想要一些纯HTML的解决方案,比如pattern属性。所以无论如何我们可以使模式属性匹配一个精确的字符串?

I want some solution with pure HTML like with pattern attribute. So anyhow we can make pattern attribute match an exact string?

推荐答案

<input type="text" name="test" pattern="CDCode" >

这篇关于我们可以只使用html模式属性匹配一个确切的字符串吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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