Javascript 欧芹验证;标签
我的页面上有一个使用Foundation-5的选项卡的表单 加载页面时,出现以下错误:Javascript 欧芹验证;标签,javascript,zurb-foundation,silverstripe,parsley.js,Javascript,Zurb Foundation,Silverstripe,Parsley.js,我的页面上有一个使用Foundation-5的选项卡的表单 加载页面时,出现以下错误: 必须在现有元素上绑定欧芹。 我认为这是因为调用parsley时表单不在Dom中,因为非活动选项卡是display:none $('form.parsley').parsley({ }) 我如何使欧芹适合我的形状 欧芹当前的调用方式如下: (function($) { $.entwine('ss.zenvalidator', function($) { $('form.parsl
必须在现有元素上绑定欧芹。
我认为这是因为调用parsley时表单不在Dom中,因为非活动选项卡是display:none
$('form.parsley').parsley({ })
我如何使欧芹适合我的形状
欧芹当前的调用方式如下:
(function($) {
$.entwine('ss.zenvalidator', function($) {
$('form.parsley').parsley({
excluded: 'input[type=button], input[type=submit], input[type=reset], input[type=hidden], :hidden, .ignore-validation'
});
$('.field').entwine({
getFormField: function() {
var rtn = this.find('[name='+this.getFieldName()+'], [name="'+this.getFieldName()+'[]"]');
},
getFieldName: function() {
return this.attr('id');
},
getFieldValue: function() {
return this.getFormField().val();
},
evaluateEqualTo: function(val) {
return this.getFieldValue() === val;
},
evaluateNotEqualTo: function(val) {
return this.getFieldValue() !== val;
},
evaluateLessThan: function(val) {
num = parseFloat(val);
return this.getFieldValue() < num;
},
evaluateGreaterThan: function(val) {
num = parseFloat(val);
return parseFloat(this.getFieldValue()) > num;
},
evaluateContains: function(val) {
return this.getFieldValue().match(val) !== null;
},
evaluateEmpty: function() {
return $.trim(this.getFieldValue()).length === 0;
},
evaluateNotEmpty: function() {
return !this.evaluateEmpty();
},
evaluateChecked: function() {
return this.getFormField().is(":checked");
}
});
$('.field.validation-logic').entwine({
onmatch: function () {
masters = this.getMasters();
for(m in masters) {
this.closest('form').find('#'+masters[m]).addClass("validation-logic-master");
}
},
getLogic: function() {
return $.trim(this.getFormField().data('validation-logic-eval'));
},
parseLogic: function() {
js = this.getLogic();
result = eval(js);
return result;
},
getMasters: function() {
return this.getFormField().data('validation-logic-masters').split(",");
}
});
$('.field.optionset').entwine({
getFormField: function() {
f = this._super().filter(":checked");
return f;
}
});
$('.field.optionset.checkboxset').entwine({
evaluateHasCheckedOption: function(val) {
this.find(':checkbox').filter(':checked').each(function() {
return $(this).val() === val || $(this).getLabel() === val;
})
},
evaluateHasCheckedAtLeast: function(num) {
return this.find(':checked').length >= num;
},
evaluateHasCheckedLessThan: function(num) {
return this.find(':checked').length <= num;
}
});
$('.field input[type=checkbox]').entwine({
getLabel: function() {
return this.closest('form').find('label[for='+this.attr('id')+']');
}
});
$('.field.validation-logic.validation-logic-validate').entwine({
testLogic: function() {
this.getFormField().toggleClass('ignore-validation', this.parseLogic());
}
});
$('.field.validation-logic.validation-logic-exclude').entwine({
testLogic: function() {
this.getFormField().toggleClass('ignore-validation', !this.parseLogic());
}
});
$('.field.validation-logic-master :text, .field.validation-logic-master select').entwine({
onmatch: function() {
this.closest(".field").notify();
},
onchange: function() {
this.closest(".field").notify();
}
});
$('.field.validation-logic-master :checkbox, .field.validation-logic-master :radio').entwine({
onmatch: function() {
this.closest(".field").notify();
},
onclick: function() {
this.closest(".field").notify();
}
});
$('.field.validation-logic-master').entwine({
Listeners: null,
notify: function() {
$.each(this.getListeners(), function() {
$(this).testLogic();
});
},
getListeners: function() {
if(l = this._super()) {
return l;
}
var self = this;
var listeners = [];
this.closest("form").find('.validation-logic').each(function() {
masters = $(this).getMasters();
for(m in masters) {
if(masters[m] == self.attr('id')) {
listeners.push($(this));
break;
}
}
});
this.setListeners(listeners);
return this.getListeners();
}
});
});
})(jQuery);
(函数($){
$.entwine('ss.zenvalidator',函数($){
$('form.parsley')。欧芹({
排除:“输入[类型=按钮]、输入[类型=提交]、输入[类型=重置]、输入[类型=隐藏]、:隐藏、.忽略验证”
});
$('.field')。纠缠({
getFormField:函数(){
var rtn=this.find(“[name=”+this.getFieldName()+”],[name=“”+this.getFieldName()+“[]”);
},
getFieldName:函数(){
返回此.attr('id');
},
getFieldValue:函数(){
返回此.getFormField().val();
},
evaluateEqualTo:函数(val){
返回这个.getFieldValue()==val;
},
evaluateNotEqualTo:函数(val){
返回此.getFieldValue()!==val;
},
evaluateLessThan:函数(val){
num=parseFloat(val);
返回此.getFieldValue()num;
},
evaluateContains:函数(val){
返回此.getFieldValue().match(val)!==null;
},
evaluateEmpty:函数(){
返回$.trim(this.getFieldValue()).length==0;
},
EvaluateNotEntry:函数(){
return!this.evaluateEmpty();
},
evaluateChecked:函数(){
返回此值。getFormField()为(“:选中”);
}
});
$('.field.validation logic')。纠缠({
onmatch:function(){
masters=this.getMasters();
(硕士学位m){
this.closest('form').find('#'+masters[m]).addClass(“验证逻辑master”);
}
},
getLogic:function(){
返回$.trim(this.getFormField().data('validation-logic-eval');
},
parseLogic:function(){
js=this.getLogic();
结果=eval(js);
返回结果;
},
getMasters:function(){
返回此.getFormField().data('validation-logic-masters').split(“,”);
}
});
$('.field.optionset')。纠缠({
getFormField:函数(){
f=此._super().过滤器(“:选中”);
返回f;
}
});
$('.field.optionset.checkboxset')。纠缠({
evaluateHasCheckedOption:函数(val){
this.find(“:checkbox”).filter(“:checked”).each(函数(){
返回$(this).val()==val | |$(this).getLabel()==val;
})
},
evaluateHasCheckedAtLeast:函数(num){
返回此.find(':checked')。长度>=num;
},
evaluateHasCheckedLessThan:函数(num){
返回这个。find(“:checked”)。length我认为以下内容应该足够了:(未测试)
这就足够了:)-对于其他人来说,我必须先消除很多其他的东西,比如facebook js,网站主js文件中不同版本的jquery等。一旦消除了这些东西,实际上只是标签打破了欧芹,这很好。谢谢!
$('form.parsley').entwine({
onmatch: function() {
$(this).parsley({
excluded: 'input[type=button], input[type=submit], input[type=reset], input[type=hidden], :hidden, .ignore-validation'
});
}
});