-
Notifications
You must be signed in to change notification settings - Fork 91
Multiple choice validator #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
会不会 data-group=3-1, data-group=3-2, data-group=3-3 比较好?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果是用作分组,我也考虑过用 data-group,只是 3-1 这样区分每一个元素可能没什么必要,因为需要额外处理。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看这个实现:
Line 159 in ec7d36b
| linkageValidate = function($item, klass, isErrorOnParent){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3-1 看上去虽然比更适合,但是操作难度更大,以社交类表单的兴趣调查为例,假设已有 12 个选择项,12-N,如果这时候增删选项,意味着所有 HTML 都可能需要改,如果需要改动顺序,那更容易改错。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
考虑一下循环输出,代码总有办法 dry,而且,1,4 这种也需要把所有项变成 1,3 如果删除一项的话;另外,从语义上看,3-1 这种更好理解。大家都知道是3个中的第1个
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1,4 这种其实会忽略掉后面的,只取第一个的值,至于用 , 是从正则那借过来,因为这货和 3-1 的区别在于,它只是一个区间。
3-1、3-2 和 3-3 只能告诉别人「有多少个」、「这是第几个」,但 1,4 的意思则是「至少 1 个,最多 4 个」。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3-1、3-2 这种方法用在 group 上我没意见,但是用在 limits 上就不适合,如果只是用 - 代替 , 那也可以,但也是用在 data-limits 上,而不是 data-group。
|
看完代码发现这个方法添加后导致整个代码很乱 |
|
要么我们这个关掉吧,有点混乱。 |
|
不用关吧?因为一般主 repo 还在更新的话,很少人关注 fork,如果有人有兴趣可以参与讨论,讨论完了,我要继续改可以在这里继续提交,然后 review,有个记录方便很多。 |
|
ok 在 2012-10-22,上午11:45,Chris Yip [email protected] 写道:
|
…multiple-choice-validator Conflicts: validator.js
…multiple-choice-validator Conflicts: validator.js
通过
data-limits来实现之前的AorB效果,好处是可以支持随意的搭配,不一定是 A or B。同时改了一下
validate和validateForm相关的几个函数,用更高效的方法去处理。