How get custom fields vendor registration to use 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!

Multi Vendor Marketplace Plugin | WCFM Marketplace Forums WC Vendors How get custom fields vendor registration to use validation ?

Viewing 1 reply thread
  • Author
    Posts
    • #128162
      lukas_smith
      Participant

      I have own fields as HTML with own name
      <input type="text" maxlength="26" id="bank_account-100" name="wcfmvm_custom_infos[bank_account]" onkeypress="return event.charCode >= 48 && event.charCode <= 57" class="wcfm-text" value="" placeholder="" data-required="1" data-required_message="Acc no. this field is req.">

      What i need to do is when i click registration i would add filtr with own function in there for this fields name wcfmvm_custom_infos[bank_account] and calculate is bank acc no is correct? If not return false with message

      Is any way to do this using filter ? i dont wanna change code in core fiels

    • #128367

      Hello,

      Add this js in your theme’s js file –

      jQuery(document).ready(function ($) {
          if($('#wcfm_membership_registration_form #bank_account').length > 0) {
             $( document.body ).on( 'wcfm_form_validate', function( event, validating_form ) {
                $form = $(validating_form);          
                $wcfm_is_valid_form = false;
                var is_valid = checkStrength($('#bank_account').val());
                if(is_valid) {
                  $wcfm_is_valid_form = true;
                } else {
                  $('#bank_account').removeClass('wcfm_validation_success').addClass('wcfm_validation_failed');      
                  $('#bank_account').addClass('wcfm_validation_failed');      
                    
                  $('#wcfm_membership_container .wcfm-message:not(.email_verification_message, .sms_verification_message)').html( '<span class="wcicon-status-cancelled"></span>' + $('#bank_account').data('mismatch_message') ).addClass('wcfm-error').slideDown();
                  $wcfm_is_valid_form = false;
                }         
            });
          }
         
        function checkStrength(accno) {   
          if(isNaN(accno)){
            return $wcfm_is_valid_form = false;
          } else {
            return $wcfm_is_valid_form = true;
          }
        }
         
      });

      And add this code in your theme’s functions.php –

      add_filter( 'wcfm_membership_registration_fields_username', function( $wcfm_register_field ) {
      	$wcfm_register_field["bank_account"] = array( 'label' => __('Bank account', 'wc-multivendor-membership') , 'type' => 'text', 'custom_attributes' => array( 'required' => 1 , 'required_message' => __( 'Acc no. this field is req.', 'wc-multivendor-membership' ),'mismatch_message' => __( 'Invalid Bank Account Number.', 'wc-multivendor-membership' ) ), 'class' => 'wcfm-text wcfm_ele ', 'label_class' => 'wcfm_ele wcfm_title', 'value' => $bank_account );
      	return $wcfm_register_field;
      },15);

      Thanks.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.