Validate - if at least one of two fields has content

We require users to provide an email address or a phone number or both.

What are some ideas to configure validation to provide error message if both fields are blank on submit?

Thanks

Radzen provides 6 diffrent validators for you to use in the Radzen IDE. They all have diffrent purpose.

In your case you want the fields to be required to fill in and therefor you want to use the RequiredValidator.
More info Here

image

1 Like

Thanks for the info.

TextBox 1
RequiredValidator 1
TextBox 2
RequiredValidator 2

If TextBox 1 or TextBox 2 has content, then turn off RequiredValidator 1 and RequiredValidator 2

That is how the validator works. If the textbox bind to the validator does not have content then the validator will display a message. If the textbox bind to the validator has content then the validator will not display a message.

Be sure to bind the validtor to a component

image

I agree that is the out of the box functionality but I have another use case as described above.

I thought there might be a way using the Visible property (To make the validator conditional you can set its Visible property. When set to false the validator will not run.) and the Change event to disable both Validators.

void Change (? ?){
if(TextBox1.value is null and TextBox2.value is null){
visible = false
}