<p>Is there a way to create conditional validation on 2 fields related to the same desired input using the Charge plugin? The Reason plugin does not work when defining fields in the CP->Charge->Settings->Field view.</p>

<p>I have a set of radio buttons and a text field for the user to input a chosen value. The user can either choose the buttons or type in a numeric value into the text field. However, it's possible that the user can simply <em>not</em> choose a value from neither the radio buttons nor type in a value into the text field.</p>

<p>I see in the documentation that there is an <a href="http://squarebit.co.uk/software/craft/charge/usage/developer/hooks-and-events#event-onBeforeCharge" rel="nofollow noreferrer"><code>onBeforeCharge</code> event</a> that can be used, so perhaps I could create a custom validation rule there, but I don't know if that should be defined in a template or in Javascript. Any ideas?</p>

<p>Thanks.</p>

CC BY-SA 3.0
2017-01-04T19:58:24.203Z
Hey @tofirius – feel free to [add a feature request](https://github.com/mmikkel/Reasons-Craft/issues) for Charge support in Reasons, and I might get around to it (sooner or later, but less chance I forget...)
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2017-01-04T21:04:27.910Z
Sounds good! I submitted the feature request. Thanks for the clever plugin, by the way. As soon as I'm up to speed, I hope to start writing some plugins of my own.
tofirius
<plugins><plugin-charge>
Charge form with conditional validation
# Charge form with conditional validation

(Asked by: username_0 on 2017-01-04)

Is there a way to create conditional validation on 2 fields related to the same desired input using the Charge plugin? The Reason plugin does not work when defining fields in the CP->Charge->Settings->Field view.

I have a set of radio buttons and a text field for the user to input a chosen value. The user can either choose the buttons or type in a numeric value into the text field. However, it's possible that the user can simply *not* choose a value from neither the radio buttons nor type in a value into the text field.

I see in the documentation that there is an [`onBeforeCharge` event](http://squarebit.co.uk/software/craft/charge/usage/developer/hooks-and-events#event-onBeforeCharge) that can be used, so perhaps I could create a custom validation rule there, but I don't know if that should be defined in a template or in Javascript. Any ideas?

Thanks.

**Tags:** plugins, plugin-charge

> **Comments:**
> **username_1**: Hey @username_0 – feel free to [add a feature request](https://github.com/mmikkel/Reasons-Craft/issues) for Charge support in Reasons, and I might get around to it (sooner or later, but less chance I forget...)  
> **username_0**: Sounds good! I submitted the feature request. Thanks for the clever plugin, by the way. As soon as I'm up to speed, I hope to start writing some plugins of my own.  

---

## 0 answers

