• Hi,

    I am trying to customize/extend the WooCommerce plugin; specifically the billings address form after login. The form uses classes like “validate-required” and “validate-phone” for validation of its input elements.

    I have searched the internet and I cannot find such use of classes for validation anywhere. My guess was that you were using JQuery validation plugin but the website shows a completely different method of validation: they do not employ the classes like “validate-required” but instead use scripts like

    
    $( "#myform" ).validate({
      rules: {
        agree: {
          required: true
        }
      }
    });
    

    I found something similar to it on this link, but even that has a different format. It looks more like
    class=”validate[required,custom[phone]]

    Moreover on the Jquery Validation website, there is no validation method for “phone” instead they have one for “phoneUS” provided as an addon. So, my guess would be that all these classes are provided by WooCommmerce itself with custom validation functions provided as hooks. But, when I search for validation hooks in the source code, I did not find anything matching “validate-phone”.

    When I tried to debug it using browser, I found out that client-side validation is actually not working (except for email). The validation is done after the form is submitted by PHP.

    So what is the purpose of classes like “validate-phone”? Is it old code that has been carried over to the current version or is it there for future use? Do there exist custom functions for client-side validation in WooCommerce which I might have missed?

    Please enlighten me. I will be grateful for your help.

    Thanks,
    Ashish

    The page I need help with: [log in to see the link]

  • The topic ‘WooCommerce form validation’ is closed to new replies.