我没有'我不理解js的结构
I don't understand that js construction
我有代码
t.prototype.checkFields = function () {
var e = this,
t = this.$container.find('.form-fieldset'),
a = 0;
return t.filter(':visible').each(function (t, i) {
var s = $(i),
n = s.find('input[type="text"], input[type="password"], input[type="email"]'),
r = n.data('write-id');
- 1 === e.settings.emptyIgnoring.indexOf(r) && n.length && !n.prop('disabled') && (n.val().trim() || (a++, s.addClass('is-js-error').find('.form-fieldset__error').html('Заполните поле')))
}),
a
},
如果输入为空,但我不知道条件是什么时候发生的,写下文本,我看不到if (...) then write text
。
为什么addClass与&;?添加类时返回什么,对吗?
那是什么?
我很少读到关于原型的内容,在引导程序和jQuery源中可以看到
- 1 === e.settings.emptyIgnoring.indexOf(r) //indexOf return r position, and is -1 if not found for example one string in another
&& n.length // that mean that length of n is bigger than 0
&& !n.prop('disabled') //is not set attribute disabled=true is equal i think with attr('disabled')==true
&& (n.val().trim() //removes newlines, spaces and other from the beginning and end of the n value
|| (a++, //increment but why is need here
s.addClass('is-js-error') //add class name
.find('.form-fieldset__error') // find child element with class form-fieldset__error
.html('Заполните поле'))) // set the html to element with class form-fieldset__error
表单提交时发送的帖子请求是(电话和电子邮件为空,我还写了$('input').val('text');并且在发送表单和数据之后也是空的)
token[3853526949671]:4dd0e6e302563d00
source:add
captcha:Maxim
email:asdasd@mm.nn
private:1
phone:
name:
我需要填充输入并传递验证函数,该函数返回输入为空的文本,但返回$('input[type=text]').val('some-text');并提交表单给我输入的文本没有用文本填充,我认为该功能显示标签和块表单执行后的
用一些注释美化了函数的版本
返回包含空文本、密码或电子邮件输入的可见表单字段集的数量
忽略禁用的输入和emptyIgnoring
-黑名单上的输入。
对代码做了一些细微的更改。
t.prototype.checkFields = function () {
var ignore = this.settings.emptyIgnoring,
numEmptyInputs = 0;
this.$container.find('.form-fieldset:visible').each(function (i, node) {
var $node = $(node),
$inputs = $node.find('input[type="text"], input[type="password"], input[type="email"]'),
writeId = $inputs.data('write-id');
//writeId is not in the Array `settings.emptyIgnoring`
//this node contains at least one text-, password- or email-input field
//the input is not disabled (actually only checks the first element)
//the input contains some none-whitespace characters
if(ignore.indexOf( writeId ) === -1 && $inputs.length > 0 && !$inputs.prop('disabled') && !$inputs.val().trim()){
numEmptyInputs++;
$node.addClass('is-js-error');
$node.find('.form-fieldset__error').html('Заполните поле');
}
});
return numEmptyInputs;
},
相关文章:
- 如何将我的json结构转换为C3.js所需的列结构
- JS库支持各种数据结构?(如爪哇的番石榴)
- 使用angularjs和node.js时的Web应用程序文件夹结构
- 如何在js中实现树结构类型的表单动态填充
- Node JS,传统的数据结构?(如Set等),任何类似Java.util的node
- xml文件在js项目目录结构中的位置
- 文件结构:使用索引.js文件级联访问子模块或子文件
- 从d3.js中的csv创建树层次结构
- 下划线扩展方法和结构.js子类
- 如何使用结构 JS 实现对比度
- 文本框导致结构 JS 中的字体出现问题
- 如何使用 OnClick 事件更改结构 JS 的覆盖图像
- 当客户端是服务器时,使用 client-JS 读取文件结构
- 结构 JS:如何防止扩展活动组
- 从knockout.js中的另一个对象更新一个深度结构化的javascript对象
- 展平多个嵌套层次结构数组-d3.js
- img目录react.js的结构
- 我没有'我不理解js的结构
- 具有JS结构棘手的网站
- 护照和Node.JS结构