Can anyone help me please! My question is how to add or remove functionality of required on custom-field based on customer decision (shipping provider he/she has chosen)?
I know how to get the shipping provider customer has selected and how to show or hide custom-fields base on chosen shipping method. Only piece of puzzle that is missing is the validation. How to remove or add validation to fields base on shipping-methods customer has chosen.
What i have done: When searching in web I have only found how to validate forms nothing about field validation inside already existing Magento 2 form.
Hi @Beginner234
Can you please share more information to better understand the question?
What fields are you planning to validate? Do you want to add validation to the fields you add dynamically?
Thanks,
Max
What fields are you planning to validate?
I am planning on validate fields that i have added below shipping method block. Looking by chrome dev-tools the fields are located inside form html element.
Do you want to add validation to the fields you add dynamically?
I have not added those fields dynamically. I have used html instead. But if you can show me a sample that does what i have described with dynamically added fields then I am glad about it too.
I hope you do not mind if i add additional question to you. Magento 2 doc uses two ways to add additional fields they are dynamic and static. My question is: Is it wrong to add those fields by using html like in this module has it done? I am not sure if I should be using this solution.