Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the simplest ways that TextBox can only enter numbers in asp.net?

Shulou Source: shulou.com Published: 2022-06-03 07:40:43 10月01日 Update

This article introduces the relevant knowledge of "what is the most concise way for TextBox to input numbers in asp.net". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The following TextBox

The copy code is as follows:

1. Add a script to the page:

The copy code is as follows:

Functionisnum ()

{

If (event.keyCode57)

{

Event.keyCode=0

}

}

two。 Add to the code:

The copy code is as follows:

Try

{

Convert.ToDouble (TextBox1.Text.Trim ())

}

Catch

{

Response.Write ("")

TextBox1.Text= ""

Page.RegisterStartupScript ("focus", "")

}

This is the end of the content of "what is the simplest way for TextBox to enter numbers only in asp.net". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Code simplicity numbers methods input content more knowledge practicality achievement next dilemma reality situation articles cases editing websites scripts industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Redmi MariaDB Docker OPPO Reno