Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ options = {

### 二、验证表单
```js
$('#form_id').validate(); // or
$('#form_id').validate(options);
$('#form_id').validator(); // or
$('#form_id').validator(options);
```

`validate` 方式支持一个 `options` 对象作为参数,该参数只在调用时供__一次性__使用。当不传参数时,`options` 使用 `validator` 的参数作为默认值。完整的对象如下描述:
`validator` 方式支持一个 `options` 对象作为参数,该参数只在调用时供__一次性__使用。当不传参数时,`options` 使用 `validator` 的参数作为默认值。完整的对象如下描述:

```js
options = {
Expand Down
3 changes: 2 additions & 1 deletion validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@
// 但通过来说我们更需要的是 checked 的状态
// 暂时去掉 radio/checkbox/linkage/aorb 的 notEmpty 检测
if(!(/^(?:radio|checkbox)$/.test(type) || aorb) && !patterns['text'](val))
return validateReturn.call(this, $item, klass, parent, 'empty')
return validateReturn.call(this, $item, klass, parent,
$item.is('[required]') ? 'empty' : '');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

意思是非 [required] 就不显示 empty 这个 class?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

也可以这么说,我想的是可以验证非[required]的字段,为空的时候认为是合法的,但是不为空的时候就需要验证。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个目前不太好加进去,建议你先在自己的项目里面改


// 二选一验证:有可能为空
if(aorb) return aorbValidate.apply(this, commonArgs);
Expand Down