How to validate integer and float input in an ASP.NET textbox
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using the code below to validate integers and floats in ASP.NET, but if I do not enter decimal then it gives me an error. <asp:TextBox ID="txtAjaxFloat" runat="server" /> <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" TargetControlID="txtAjaxFloat" FilterType="Custom, numbers" ValidChars="." runat="server" /> I also have the regular expression from What's a C# regular expression that'll validate currency, float or integer? , but it's giving a validation error if I enter only one value after the decimal.. 回答1: Use