2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Kusno
0

Hi agz86,

I hope I can help you......

In GridView template :

<asp:templatefield headertext="Amount">
   <itemstyle borderstyle="None" font-size="8pt" width="20px" />
   <headerstyle font-bold="False" width="65px" font-size="8pt"/>
         <itemtemplate>
         <asp:TextBox id="Amount" text='<% # eval("AMOUNT") %>' runat="server" width="65px"  font-size="8pt" onkeypress="keyDownNumber()" </asp:TextBox>                                                                                 
         </itemtemplate>
    </asp:templatefield>

In JavaScript :

<script language="Javascript" type="text/javascript">   
function keyDownNumber()
{ 
    var key;    
    if(navigator.appName == 'Microsoft Internet Explorer')
        key = event.keyCode;
    else
        key = event.which
        
    if ( !(key >= 48 && key <= 57) && key != 8 && key != 46 && key != 36 && key != 37)
    {
        event.returnValue = false;        
    }
}
</script>

Thanks,

Kusno

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.