Title: Client side validation issue
Last modified: August 29, 2024

---

# Client side validation issue

 *  [frensis](https://wordpress.org/support/users/frensis/)
 * (@frensis)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/client-side-validation-issue-2/)
 * Hello there,
   I’m facing an issue with client side validation and I found a thread
   with exactly the same issue but it was closed without a solution. After almost
   2 years the issue still occurs.Here the original topic by [@henrydunbar](https://wordpress.org/support/users/henrydunbar/):
   [https://wordpress.org/support/topic/issue-with-validation-3/](https://wordpress.org/support/topic/issue-with-validation-3/)
   Here a quick recap:if a user try to click the “Add to cart” button before all
   fields are ok, all fields are duplicated with ‘display: none’ so even if the 
   user back to fill all the original visible fields, client validation fail because
   duplicated hidden fields are empty.
 * Disabling client validation is a UX bad workaround because on page reload user
   must fill all fields one more time (even if he missed just one field).
   Could 
   you investigate and give a proper solution?Thanks

Viewing 1 replies (of 1 total)

 *  Thread Starter [frensis](https://wordpress.org/support/users/frensis/)
 * (@frensis)
 * [1 year, 7 months ago](https://wordpress.org/support/topic/client-side-validation-issue-2/#post-17982990)
 * After a quick search, I suppose the issue is due to something in this part of
   code in this file:
   /wc-fields-factory/assets/js/wcff-client-src.jsI hooked field
   outside form cart with a custom hook but this code clone fields in form.cart 
   on submit even if validation results fails for one/some field.The logic should
   check for a previous failed validation and update cloned fields rather than create
   new ones at every click on submit.Is it right?
 *     ```wp-block-code
       /**** Last minute cleanup operations, before the Product Form submitted for Add to Cart**/$(document).on( "submit", "form.cart", function() { console.log("on submit called");// To remove hidden field table$(".wcff_is_hidden_from_field_rule").remove();if (typeof(wccpf_opt.location) !== "undefined") {var me = $(this);$(".wccpf_fields_table").each(function() {/* Make sure it is not from related products - If show archive enabled then this happens */let liParent = $(this).closest("li.product");if (liParent && liParent.length > 0) {return;}if ($(this).closest("form.cart").length == 0) {var cloned = $(this).clone(true);cloned.css("display", "none");/* Since selected flaq doesn't carry over by Clone method, we have to do it manually *//* carry all field value to server */if ($(this).find(".wccpf-field").attr("data-field-type") === "select") {cloned.find("select.wccpf-field").val($(this).find("select.wccpf-field").val());}me.append(cloned);}});}});
       ```
   
    -  This reply was modified 1 year, 7 months ago by [frensis](https://wordpress.org/support/users/frensis/).

Viewing 1 replies (of 1 total)

The topic ‘Client side validation issue’ is closed to new replies.

 * ![](https://ps.w.org/wc-fields-factory/assets/icon-128x128.jpg?rev=2738843)
 * [WC Fields Factory](https://wordpress.org/plugins/wc-fields-factory/)
 * [Support Threads](https://wordpress.org/support/plugin/wc-fields-factory/)
 * [Active Topics](https://wordpress.org/support/plugin/wc-fields-factory/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wc-fields-factory/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wc-fields-factory/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [frensis](https://wordpress.org/support/users/frensis/)
 * Last activity: [1 year, 7 months ago](https://wordpress.org/support/topic/client-side-validation-issue-2/#post-17982990)
 * Status: not resolved