JAVA SCRIPT CODE

function NumbrOnly()
    {
    if(event.KeyCode==45 || event.KeyCode==46 || event.KeyCode==48 || event.KeyCode==49 || event.KeyCode==50 || event.KeyCode==51 || event.KeyCode==52 || event.KeyCode==53 || event.KeyCode==54 || event.KeyCode==55 || event.KeyCode==56 || event.KeyCode==57)
    {
    event.retunValue=false;
    }

<asp:TextBox ID="TextBox3" onkeypress="NumberOnly('TextBox3')" runat="server"></asp:TextBox>

WHAT IAM MISSIGN AND WHEN I WRITE event. then after 'dot' it doesnt show KeyCode Property PLZZZZZ HELP

Recommended Answers

All 6 Replies

Explain what you need first.
Are you intending to limit the input to your textbox to only accept specific numbers?
Should probably use validators to solve the issue.
Good luck

explain what you need first.
Are you intending to limit the input to your textbox to only accept specific numbers?
Should probably use validators to solve the issue.
Good luck

i have textbox of asp.net server side control now i just want to do with java script only that user should be able to enter the numbers from 0-9,allow the user to work with delte,back space, and arrow keys i have used ajax it works fine i have used validation control of asp.net but i want to do with java script only plzzzzzz helppppppppp

<script type="text/javascript">
  function NumberOnly(){
          var t=window.event.keyCode;

          if(t>=48 & t<=57)
               return;
          window.event.keyCode=0; 
  } 
</script>
.....
<asp:TextBox ID="TextBox3" onkeypress="NumberOnly()" runat="server"></asp:TextBox>

it works fine

<script type="text/javascript">
  function NumberOnly(){
          var t=window.event.keyCode;

          if(t>=48 & t<=57)
               return;
          window.event.keyCode=0; 
  } 
</script>
.....
<asp:TextBox ID="TextBox3" onkeypress="NumberOnly()" runat="server"></asp:TextBox>

Please mark this thread as solved if you have found an answer to your question and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.