---
title: "What is better solution for validate form TextBoxs value?"  
description: "What is better solution for validate form TextBoxs value?"  
author: "Anonymous User"  
published: 2013-09-23  
updated: 2013-09-23  
canonical: https://www.mindstick.com/forum/1490/what-is-better-solution-for-validate-form-textboxs-value  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# What is better solution for validate form TextBoxs value?

In my [system](https://www.mindstick.com/articles/23411/the-most-effective-method-to-find-the-perfect-small-business-phone-system-for-your-business) has many [forms](https://www.mindstick.com/interview/34192/what-is-the-purpose-of-the-authentication-mode-forms-element-in-web-config) for [insert](https://www.mindstick.com/blog/173/executing-insert-delete-or-update-query-in-sqlserver-using-ado-dot-net) and edit [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) registers

But before to save [date](https://yourviews.mindstick.com/story/3869/propose-day-2024-exciting-date-ideas-for-you-and-your-partner) in database, I need [validate](https://www.mindstick.com/forum/33871/how-to-validate-email-address-in-javascript) any camp, validate it [values](https://www.mindstick.com/forum/327/sum-textbox-values) is empty or not, validate TextBox.Text lenght, etc...

I validated they with many many if's

if (tbName.Text.Equals("")) { }

if (tbPass.Password.Equals("")) { }

if (tbEmail.Text.Equals("")) { }

if (tbTelephone.Text.Equals("")) { }

if (tbNome.Text.Length < 4) { }

if (tbPass.Password.Length < 5) { }

if (!tbEmail.Text.Contains('@')) { }

but it is very no [efficiency](https://www.mindstick.com/articles/13091/12-tips-to-boost-your-studying-efficiency) and I don't know any other solution for this

What solution is usual for this?

## Replies

### Reply by Sumit Kesarwani

Hi Ankita,

This is by hand so it will have some syntax errors

You will probably also want to implement iNotifyPropertyChanged

## Then Validation

```
public Class ValidatedText {    private string vText;    private bool valid = true;    Int23 maxLen = 0;    public bool Valid     {          get { return valid; }       set        {            if (valid == value) return;          valid = value;       }    }     public string Vtext     {         get { return vText; }       set        {            if (vText == value) return;          if (value.Len < 0)           {              Valid = false;             
            return;          }          // do additional validation here          vText = value;       }    }   public ValidatedText (string VText; Int32 MaxLen)   {   vText = Vtext; maxLen - MaxLen;   }}
```


---

Original Source: https://www.mindstick.com/forum/1490/what-is-better-solution-for-validate-form-textboxs-value

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
