I am going to validate different filelds in form. I want that some filelds which are hidden should not . be validate on click of submit button.
Here I do not want nature of relationship when form validate
{% include 'select-input' with
mod_name: 'inquiry[natureofrelationship]',
mod_class: 'contact__field select--contact',
mod_label: field_label,
mod_on_change: 'onInputChange',
mod_required: true,
mod_value: "function(){return '-'}",
mod_error: field_error,
mod_options: select_options,
mod_required: true,
mod_validator: 'topicvalidator'
%}
topicvalidator (value) {
return value && value !== ‘-’
}
Here problem is even though natureofrelationship is hidden it will throw error message : “Nature of relationship is required”.
How can i remove validation for hidden fields in js ?
Did you try setting mode_required initially to false as it is hidden in the start then turn it to true once the field is no longer hidden?
Yes tried here mod_validator: ‘topicvalidator’ is for validate the field. if i will remove that no validation
so at the selection of influencer page only natureof realtionship will show means mod_validator: ‘topicvalidator’ should add at that time only.
How can i add that ?
it is in liquid files of shopify