Click here to Skip to main content
15,890,376 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralNumberBox - a simple digits only textbox Pin
moredip12-Apr-03 8:43
moredip12-Apr-03 8:43 
Hi all,

can anyone see anything glaringly wrong with this:
public class NumberBox : TextBox
{
	protected override void OnKeyPress( KeyPressEventArgs e )
	{
		if( !char.IsDigit(e.KeyChar) && !char.IsControl(e.KeyChar) )
			 e.Handled = true;
		base.OnKeyPress( e );
	}
}


It doesn't have to be super-secure or anything (I don't care about Ctrl-V etc) cause I validate the control's Text later anyway, it's just a quick and easy way to persuade my lovely users to only enter numbers.

So I was just wondering if anyone can spot any usability problems with this? I'm not worried about
  • negative numbers
  • pasting in incorrect data, etc
  • decimal points and thousand seperators
  • TIA,

    Pete
    GeneralRe: NumberBox - a simple digits only textbox Pin
    J. Dunlap12-Apr-03 9:34
    J. Dunlap12-Apr-03 9:34 
    GeneralRe: NumberBox - a simple digits only textbox Pin
    moredip12-Apr-03 12:02
    moredip12-Apr-03 12:02 
    GeneralRe: NumberBox - a simple digits only textbox Pin
    ian mariano13-Apr-03 12:07
    ian mariano13-Apr-03 12:07 
    GeneralRe: NumberBox - a simple digits only textbox Pin
    moredip13-Apr-03 12:11
    moredip13-Apr-03 12:11 
    GeneralRe: NumberBox - a simple digits only textbox Pin
    ian mariano13-Apr-03 12:48
    ian mariano13-Apr-03 12:48 
    GeneralRe: NumberBox - a simple digits only textbox Pin
    moredip13-Apr-03 12:57
    moredip13-Apr-03 12:57 
    GeneralDebugging remoted class hosted by IIS Pin
    David Thom11-Apr-03 8:09
    David Thom11-Apr-03 8:09 
    GeneralWeb Service Problems Pin
    rantinori10-Apr-03 10:57
    rantinori10-Apr-03 10:57 
    GeneralTRYING to install .NET 1.1.... Pin
    J. Dunlap10-Apr-03 10:18
    J. Dunlap10-Apr-03 10:18 
    GeneralRe: TRYING to install .NET 1.1.... Pin
    J. Dunlap10-Apr-03 10:41
    J. Dunlap10-Apr-03 10:41 
    GeneralRe: HELP!!! TRYING to install .NET 1.1.... Pin
    J. Dunlap10-Apr-03 16:47
    J. Dunlap10-Apr-03 16:47 
    GeneralRe: HELP!!! TRYING to install .NET 1.1.... Pin
    Richard Deeming11-Apr-03 0:59
    mveRichard Deeming11-Apr-03 0:59 
    GeneralRe: HELP!!! TRYING to install .NET 1.1.... Pin
    J. Dunlap11-Apr-03 8:02
    J. Dunlap11-Apr-03 8:02 
    GeneralSame Browser and Form graphic intergace Pin
    yro10-Apr-03 6:04
    yro10-Apr-03 6:04 
    GeneralRe: Same Browser and Form graphic intergace Pin
    Stephane Rodriguez.10-Apr-03 6:33
    Stephane Rodriguez.10-Apr-03 6:33 
    GeneralInstalling Primary Interop Assemblies Pin
    Mike Dimmick10-Apr-03 3:31
    Mike Dimmick10-Apr-03 3:31 
    GeneralRe: Installing Primary Interop Assemblies Pin
    Stephane Rodriguez.10-Apr-03 6:37
    Stephane Rodriguez.10-Apr-03 6:37 
    GeneralRe: Installing Primary Interop Assemblies Pin
    Mike Dimmick12-Apr-03 5:03
    Mike Dimmick12-Apr-03 5:03 
    GeneralRe: Installing Primary Interop Assemblies Pin
    Stephane Rodriguez.12-Apr-03 6:21
    Stephane Rodriguez.12-Apr-03 6:21 
    GeneralHelp regarding debugging Pin
    Venkatraman9-Apr-03 20:12
    Venkatraman9-Apr-03 20:12 
    General.NET Strings & NULLS Pin
    Nicholas Cardi9-Apr-03 11:25
    Nicholas Cardi9-Apr-03 11:25 
    GeneralRe: .NET Strings & NULLS Pin
    Stephane Rodriguez.10-Apr-03 6:39
    Stephane Rodriguez.10-Apr-03 6:39 
    Generalfind network computers Pin
    Andrei Matei9-Apr-03 3:20
    Andrei Matei9-Apr-03 3:20 
    GeneralRe: find network computers Pin
    vishal S.21-Apr-03 1:20
    vishal S.21-Apr-03 1:20 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.