I'm trying to add a class "checked", but for some reason nothing happens. Here is the code snippet. Platform - Wordpress. Plugin - WC Fields Factory. Here is the broader part of the code, since you need to enable the changes here. Maybe I'm wrong.
this.doValidate = function( field ) {
if( field.attr("wccpf-type") !== "radio" && field.attr("wccpf-type") !== "checkbox" && field.attr("wccpf-type") !== "file" ) {
if(field.attr("wccpf-type") !== "select") {
if( this.doPatterns( field.attr("wccpf-pattern"), field.val() ) ) {
field.next().hide();
} else {
this.isValid = false;
field.next().show();
}
} else {
if (field.val() !== "" && field.val() !== "wccpf_none") {
field.next().hide();
} else {
this.isValid = false;
field.next().show();
}
}
} else if( field.attr("wccpf-type") === "radio" ) {
if( field.closest("ul").find("input[type=radio]").is(':checked') ) {
field.closest("ul").next().hide();
} else {
field.closest("ul").next().show();
this.isValid = false;
}
} else if( field.attr("wccpf-type") === "checkbox" ) {
var values = field.closest("ul").find("input[type=checkbox]:checked").map(function() {
return this.value;
}).get();
if( values.length === 0 ) {
field.closest("ul").next().show();
this.isValid = false;
} else {
field.closest("ul").next().hide();
}
} else if( field.attr("wccpf-type") === "file" ) {
if( field.val() == "" ) {
field.next().show();
this.isValid = false;
} else {
field.next().hide();
}
}
}
Aucun commentaire:
Enregistrer un commentaire