Skip to content

Commit

Permalink
update Validator doc; fixes javascript.doc spelling error
Browse files Browse the repository at this point in the history
  • Loading branch information
Minwe committed Jan 8, 2015
1 parent 0b6ebe4 commit 43faf9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jQuery 和 Zepto.js 表面看起来差不多,其实一些细节上差异很大
#### `width()`/`height()`

- Zepto.js: 由盒模型(`box-sizing`)决定
- jQery: 忽略盒模型,始终返回内容区域的宽/高(不包含 `padding``border`
- jQuery: 忽略盒模型,始终返回内容区域的宽/高(不包含 `padding``border`

jQuery [官方的说明](http://api.jquery.com/width/#width)

Expand Down
12 changes: 12 additions & 0 deletions docs/javascript/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ JS 表单验证基于 HTML5 的各项验证属性进行:
- `minchecked`/`maxchecked`: 至少、至多选择数,适用于 `checkbox`、下拉多选框,`checkbox` 时将相关属性的设置在同组的第一个元素上;
- `.js-pattern-xx`: 验证规则 class,正则库中存在的规则可以通过添加相应 class 实现规则添加。

**注意:**

HTML5 原生表单验证中 `pattern` 只验证值的合法性,也就是**可以不填,如果填写则必须符合规则**。如果是必填项,仍要添加 `required` 属性。该插件与 HTML5 的规则保持一致。

```html
<!-- 下面三种写法等效 -->
<!-- 只内置了 email url number 三种类型的正则,可自行扩展 -->
Expand Down Expand Up @@ -380,6 +384,10 @@ $(function() {
<label for="">输入一个颜色值</label>
<input type="text" class="js-pattern-colorHex" placeholder="如果填写,必须是 #xxx 或 #xxxxxx"/>
</div>
<div class="am-form-group">
<label for="">your pattern</label>
<input type="text" class="js-pattern-yourpattern" placeholder="必填,且只能填 your" required/>
</div>
<div>
<button class="am-btn am-btn-secondary">提交</button>
</div>
Expand All @@ -403,6 +411,10 @@ $(function() {
<label for="">输入一个颜色值</label>
<input type="text" class="js-pattern-colorHex" placeholder="如果填写,必须是 #xxx 或 #xxxxxx"/>
</div>
<div class="am-form-group">
<label for="">your pattern</label>
<input type="text" class="js-pattern-yourpattern" placeholder="必填,且只能填 your" required/>
</div>
<div>
<button class="am-btn am-btn-secondary">提交</button>
</div>
Expand Down

0 comments on commit 43faf9e

Please sign in to comment.