input的pattern属性

简介:

定义和用法

pattern 属性规定用于验证输入字段的模式。

模式指的是正则表达式。您可以在我们的 JavaScript 教程中阅读到这方面的内容。

注释:pattern 属性适用于以下 <input> 类型:text, search, url, telephone, email 以及 password 。

提示:请使用标准的 "title" 属性来描述模式。

语法:

<input pattern="regexp">


例子:

<!DOCTYPE HTML>

<html>

<body>

<form action="/example/html5/demo_form.asp" method="get">

国家代码:<input type="text" name="country_code" pattern="[A-z]{3}"

title="三个字母的国家代码" />

<input type="submit" />

</form>


</body>

</html>



本文转自 沉迷学习中 51CTO博客,原文链接:http://blog.51cto.com/12907581/1967754,如需转载请自行联系原作者
相关文章
|
3月前
|
Web App开发 前端开发 iOS开发
input中typedate的属性都有那些
input中typedate的属性都有那些
|
4月前
|
前端开发
input去掉输入框type为number时的上下箭头的实现方法
input去掉输入框type为number时的上下箭头的实现方法
39 0
|
6月前
|
数据安全/隐私保护
input表单的23个type属性
input表单的23个type属性
|
7月前
input type=file过滤图片
input type=file过滤图片
28 0
|
8月前
|
设计模式 uml
空对象模式(Null Object Pattern)
空对象模式(Null Object Pattern)不属于GoF设计模式,但是它作为一种经常出现的模式足以被视为设计模式了。其具体定义为设计一个空对象取代NULL对象实例的检查。NULL对象不是检查控制,而是反映一个不做任何动作的关系。这样的NULL对象也可以在数据不可用的时候提供默认的行为,属于行为型设计模式。
54 0
|
8月前
|
vr&ar
Testpattern
Testpattern
36 0
|
9月前
|
JavaScript 前端开发 数据安全/隐私保护
input的23种属性
input的23种属性
|
JavaScript
input中placeholder属性
input中placeholder属性
input中placeholder属性
|
Web App开发 JavaScript 数据安全/隐私保护
ie8下修改input的type属性报错
ie8下修改input的type属性报错
ADI
|
JavaScript 前端开发 API
[记录] input[type=file]属性详解
[记录] input[type=file]属性详解
ADI
232 0