In ASP.NET, you will probably use the RegularExpressionValidator control, bound to your TextBox control. Look up the MSDN usage for more detail. You can use the Regular Expression patterns suggested above. My only additional input is that the RegularExpressionValidator control will treat an empty textbox as valid input (regardless of the pattern used). So, if you don't want to allow an empty input, you will need to test on either the client or server side for that condition. Other than that, the RegularExpressionValidator will do a nice job.
Les Potter, Xalnix Corporation,
Yet Another C# Blog