# Validate - if at least one of two fields has content

**URL:** <https://forum.radzen.com/t/validate-if-at-least-one-of-two-fields-has-content/10150>\
**Category:** Blazor Server\
**Created:** [February 17, 2022, 12:08am UTC](https://forum.radzen.com/t/validate-if-at-least-one-of-two-fields-has-content/10150 "2022-02-17T00:08:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![barry8schneider](https://forum.radzen.com/user_avatar/forum.radzen.com/barry8schneider/32/9777_2.png) [@barry8schneider](https://forum.radzen.com/u/barry8schneider)\
**Post date:** [February 17, 2022, 12:08am UTC](https://forum.radzen.com/t/validate-if-at-least-one-of-two-fields-has-content/10150/1 "2022-02-17T00:08:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gottegubben](https://forum.radzen.com/letter_avatar_proxy/v4/letter/g/ecccb3/32.png) [@Gottegubben](https://forum.radzen.com/u/Gottegubben)\
**Post date:** [February 17, 2022, 8:19am UTC](https://forum.radzen.com/t/validate-if-at-least-one-of-two-fields-has-content/10150/2 "2022-02-17T08:19:17Z")

</div>

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](https://www.radzen.com/documentation/required-validator/)

 ![image](https://forum.radzen.com/uploads/default/original/2X/7/74e797d253eb00f8ccfd2aba2dca2899a96413e4.png)

---

<div class="post-metadata">

**Author:** ![barry8schneider](https://forum.radzen.com/user_avatar/forum.radzen.com/barry8schneider/32/9777_2.png) [@barry8schneider](https://forum.radzen.com/u/barry8schneider)\
**Post date:** [February 17, 2022, 2:53pm UTC](https://forum.radzen.com/t/validate-if-at-least-one-of-two-fields-has-content/10150/3 "2022-02-17T14:53:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Gottegubben](https://forum.radzen.com/letter_avatar_proxy/v4/letter/g/ecccb3/32.png) [@Gottegubben](https://forum.radzen.com/u/Gottegubben)\
**Post date:** [February 17, 2022, 2:56pm UTC](https://forum.radzen.com/t/validate-if-at-least-one-of-two-fields-has-content/10150/4 "2022-02-17T14:56:54Z")

</div>

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](https://forum.radzen.com/uploads/default/original/2X/7/747531a7eedd547cd3f59ec97faa3f1a7072a39a.png)

---

<div class="post-metadata">

**Author:** ![barry8schneider](https://forum.radzen.com/user_avatar/forum.radzen.com/barry8schneider/32/9777_2.png) [@barry8schneider](https://forum.radzen.com/u/barry8schneider)\
**Post date:** [February 17, 2022, 3:30pm UTC](https://forum.radzen.com/t/validate-if-at-least-one-of-two-fields-has-content/10150/5 "2022-02-17T15:30:22Z")

</div>

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.

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

```
