How do I filtered TextBox with an Integer Data Type

验证用户输入的是否为整型。你可以使用下面正则表达式:

< asp:TextBox ID = " txtWorkNumber "  runat = " server "  onkeyup = " value=value.replace(/[^\d]/g,'') "
                    onbeforepaste
= " clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,'')) "
                    CssClass
= " textbox " ></ asp:TextBox >

 

或者使用asp.net验证Comparevalidator,有一个Type="Integer",如:

  < asp:CompareValidator ID = " CompareValidator3 "  runat = " server "  ControlToValidate = " txtNumber "
                                                                            
Type = " Integer "  Operator = " dataTypeCheck "  ErrorMessage = " 招聘人数栏位,非有效数值! " ></ asp:CompareValidator >

你可能感兴趣的:(Integer)