---
title: "How to make a text box to accept only number based on a condition?"  
description: "How to make a text box to accept only number based on a condition?"  
author: "Anonymous User"  
published: 2013-09-23  
updated: 2013-09-23  
canonical: https://www.mindstick.com/forum/1478/how-to-make-a-text-box-to-accept-only-number-based-on-a-condition  
category: "wpf"  
tags: ["wpf"]  
reading_time: 1 minute  

---

# How to make a text box to accept only number based on a condition?

How to make a [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) to [accept](https://yourviews.mindstick.com/view/81278/we-have-to-accept-that-roger-federer-is-the-richest-one) only number? when my label.text is gms or rs or knot, then respective textbox accept only numbers. when label.text is [character](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) it has allow only character value.

Example:gms: 1200

character:[black](https://yourviews.mindstick.com/view/83102/badi-elaichi-black-cardamom-health-benefits)

knot:5

rs:80

character:pink

Thanks in advance.

## Replies

### Reply by Sumit Kesarwani

Hi Ankit,\

Apply a regular validator on your text box with validation expression "^[0-9]" which accept only numbers initially make it disabled

you can then enable disable it according to the text of your label making the text box to accept all or only numbers.


---

Original Source: https://www.mindstick.com/forum/1478/how-to-make-a-text-box-to-accept-only-number-based-on-a-condition

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
