---
title: "How to i get my textbox to only allow numbers 1-14?"  
description: "How to i get my textbox to only allow numbers 1-14?"  
author: "Lillian Martin"  
published: 2014-11-25  
updated: 2014-11-26  
canonical: https://www.mindstick.com/forum/12689/how-to-i-get-my-textbox-to-only-allow-numbers-1-14  
category: "asp.net"  
tags: ["asp.net mvc"]  
reading_time: 1 minute  

---

# How to i get my textbox to only allow numbers 1-14?

This is what i have so far, but I am obviously [getting an error](https://answers.mindstick.com/qa/95244/why-do-you-keep-getting-an-error-message-ox800ccc0b).

```
try{    dblNights = Convert.ToDouble(txtNights.Text);     if (dblNights > 1 && 14)    {    }    else    {        string script = "alert(\"Number of Nights Must be between 1 and 14!\");";        ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);        txtNights.Focus();    }}//End Try catch{    string script = "alert(\"Number of Nights Must be an Integer!\");";    ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);     txtNights.Focus();}//End Catch
```

I am not quite sure what to do to make show an error box if numbers besides 1-14 are entered. Everything else is working, just not that. What am I [doing wrong](https://answers.mindstick.com/qa/36736/what-are-indians-doing-wrong-on-whatsapp)?

Thank you.

## Replies

### Reply by Anonymous User

You are not properly using the Logical AND operator.

This:

if (dblNights > 1 && 14)

{

}

Must be:

if (dblNights >= 1 && dblNights <= 14)

{

/*valid range some thing here*/

}


---

Original Source: https://www.mindstick.com/forum/12689/how-to-i-get-my-textbox-to-only-allow-numbers-1-14

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
