Vendor registration validation

We're shifting our Forum based support to a more dedicated support system!

We'll be closing our Forum support from 10th June, 2020 and move to Email Support assistance.

  • If you are a WCFM premium add-ons user, contact us- here
  • Want to know more before buying our add-ons? Send Pre sale queries- here
  • If you are a WCFM free user, please open a support ticket at WordPress.org
  • For WCFM App related queries, reach us- here
From now the forum will be read-only!

Viewing 5 reply threads
  • Author
    Posts
    • #136228
      Flo
      Participant

      Hello,

      I want to know how can I validate individually the text input of the vendors, when they write somethinginto the registration form ?

      For exmaple the E-mail adress should must have an @-sign.

      I justified the vendor registration by adding a custom ZIPCODE field. I excluded the adress from registration form. I know there wasa zipcode in it, but I wanted to have an own one.
      How can I validate if the ZIPCODE consists of 5 numbers and starts with number 1 ?
      I was able to validate the zipcode in the checkout process. But I don’t know the needed script for the registration form in WCFM.

      Kind regards,
      Flo

    • #136444

      Hello,

      Add below script/js in your theme’s js file, and modify the validation logic-

      if($("#wcfm_membership_registration_form input[name='wcfmvm_custom_infos[custom-zipcode]']").length > 0) {
             $( document.body ).on( 'wcfm_form_validate', function( event, validating_form ) {
                $form = $(validating_form);          
                $wcfm_is_valid_form = false;
                var is_valid = checkStrength($("#wcfm_membership_registration_form input[name='wcfmvm_custom_infos[custom-zipcode]']").val());
                if(is_valid) {
                  $wcfm_is_valid_form = true;
                } else {
                  $("#wcfm_membership_registration_form input[name='wcfmvm_custom_infos[custom-zipcode]']").attr('data-mismatch_message','Invalid Zipcode Number.');
                  $("#wcfm_membership_registration_form input[name='wcfmvm_custom_infos[custom-zipcode]']").removeClass('wcfm_validation_success');      
                  $("#wcfm_membership_registration_form input[name='wcfmvm_custom_infos[custom-zipcode]']").addClass('wcfm_validation_failed');      
                    console.log('false');
      
                  $('#wcfm_membership_container .wcfm-message:not(.email_verification_message, .sms_verification_message)').html( '<span class="wcicon-status-cancelled"></span>' + $("#wcfm_membership_registration_form input[name='wcfmvm_custom_infos[custom-zipcode]']").data('mismatch_message') ).addClass('wcfm-error').slideDown();
                  $wcfm_is_valid_form = false;
                }         
            });
          }
         
       /*modify the validation logic here*/
        function checkStrength(zipcode) {   
          if(isNaN(zipcode)){      
            return $wcfm_is_valid_form = false;
          } else {
            return $wcfm_is_valid_form = true;
          }
        }

      replace the #wcfm_membership_registration_form input[name='wcfmvm_custom_infos[custom-zipcode]'] with your field selector.

      Thanks.

    • #136583
      Flo
      Participant

      Thank you, is there another way where I can usethe functions.php ?
      For example with add_action(‘wcfm_membership_registration_form’,function(){
      })

    • #136596

      Hello,

      Using this code –

      add_action('wcfm_membership_registration_form',function(){
      })

      You can add custom field in the registration form, if you want without using WCFM dashboard->Settings->Vendor Regstration-> Custom field.
      But to add validation as per your requirement in a custom field, you need to write js script as we mentioned previous reply.

      Thanks.

    • #140532
      Flo
      Participant

      Hello,

      I added the script in the theme.js. But I am not able to modify it properly.
      I called my custom zipcode “Postleitzahl” and I want to check if the Postleitzahl starts with 5.
      How can I modify the script ?

      Is it like
      input[name=’wcfmvm_custom_infos[custom-zipcode]’]
      modiefied to
      input[name=’wcfmvm_custom_infos[Postleitzahl]’] ?

      Where does the (zipcode) in the validation logic came from ?

      Can somebody help me please ?

      • #140659

        Hello,

        In the function – “checkStrength” you have to modify the validation logic.
        Example –

        function checkStrength(zipcode) {
            var firstDigit = zipcode.toString().charAt(0);
            if(isNaN(zipcode) || (firstDigit!=5)){      
              return $wcfm_is_valid_form = false;
            } else {
              return $wcfm_is_valid_form = true;
            }
          }

        Thanks.

    • #140699
      Flo
      Participant

      THank you,

      can you answer please my other two questions ?
      I would like to understand the script, so I can use it for all the other fields in the registration form.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.