DevExpress控件使用之ASPxTextBox 只输入数字

<dx:ASPxTextBox ID="tbWhereID" SkinID="txtEdit" runat="server" Width="30" Height="23px">
    <ClientSideEvents KeyPress="function(s, e) {
                          var theEvent = e.htmlEvent || window.event;
                          var key = theEvent.keyCode || theEvent.which;
                          key = String.fromCharCode(key);
                          var regex = /[0-9]/;

                          if(!regex.test(key))
                          {
                              theEvent.returnValue = false;
                              if(theEvent.preventDefault) 
                                  theEvent.preventDefault();
                          }    
                      }" />
</dx:ASPxTextBox>

 

原文:http://www.oschina.net/code/snippet_782086_17694

 

posted @ 2013-02-20 14:05  pocketz  阅读(2684)  评论(3编辑  收藏  举报