Ignore form field insert if blank

I have a form field that is shown/hidden depending on a radio selection before it.

If it is hidden then the value will be blank and the database will use the default value of 1.

If it is shown then it is validated to require a value of 2 to 10 which needs to be inserted.

If it is hidden and has a blank value how do get the database insert to ignore it?

Thanks in advance!

How about using a conditional region around the input instead of using Hide… that way it will not be sent to the server when blank, so then you can use your default 1 logic.

It would be more appropriate to use dynamic required/disabled attributes, instead of using a conditional region for fewer fields.
dmx-bind:required="somecondition==1"

Thanks @mebeingken. Well my preference would be to use as is which is using show. Only because there are other fields that are also shown or hidden which have certain validation rules depending on the number entered in the input in question. Subsequently if I were to try the conditional region. How would I do that exactly? :grimacing:

Why do you think it is "more appropriate" rather than just another way of doing this?

Then evaluate what comes to the server, and deal with it there.

Conditional regions require additional DIV surrounding the input. And just for one field, it does not make sense to me.
We use a mix of both approaches depending on the form.
If there are multiple fields we need to disable, we use CR. If there are a couple, we use hide & disabled dynamic bidnings.

Ok thanks @mebeingken… and @sid … but to be honest i’m still none the wiser on what I need to do here. I’m very much on the learning curve with his!

Thanks @sid I think this is probably what I need. So i’ve added a ‘disabled dynamic attribute’ with a condition that uses the value of the radio group above it. (see screen shot ) … which seems to work.

1 Like

Just to add reference to what @mebeingken suggested on this regarding using conditional regions. and in fact what @sid mentioned that in certain situations he uses both show/hide and CRs. I have discovered that using both methods combined was the solution for this particular section of the form.
So thank you both!