Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Vendor registration validation
- This topic has 6 replies, 2 voices, and was last updated 4 years, 6 months ago by Flo.
- AuthorPosts
- May 28, 2020 at 9:48 pm #136228FloParticipant
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 - May 29, 2020 at 12:25 pm #136444Sarmistha ChakrabortyMember
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.
- May 29, 2020 at 9:24 pm #136583FloParticipant
Thank you, is there another way where I can usethe functions.php ?
For example with add_action(‘wcfm_membership_registration_form’,function(){
}) - May 29, 2020 at 10:43 pm #136596Sarmistha ChakrabortyMember
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.
- June 11, 2020 at 1:25 pm #140532FloParticipant
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 ?
- June 11, 2020 at 10:41 pm #140659Sarmistha ChakrabortyMember
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.
- June 12, 2020 at 2:09 am #140699FloParticipant
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.
- AuthorPosts
- You must be logged in to reply to this topic.