Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to use integer and character textbox .. in integer textbox character key should be disabled..and vice versa in asp.net using vb
how i can do it..
plz guide me..
thnx
Posted

Easiest way is to do it in Javascript:
XML
<html>
  <head>
    <script language=Javascript>
       <!--
       function isNumberKey(evt)
       {
          var charCode = (evt.which) ? evt.which : event.keyCode;
          if (charCode != 46 && charCode > 31  && (charCode < 48 || charCode > 57))
             return false;
          return true;
       }
       //-->
    </script>
  </head>
  <body>
    <input id="tbChar" onkeypress="return isNumberKey(event)" type="text" name="tbChar">
  </body>
</html>
That allows '.' 0' - '9' only, and it is pretty simple for you to reverse.
 
Share this answer
 
What you need is a filtering mechanism for your textboxes. Here is a small javascript framework to perform this task only. check this out and you should be able to do what you want in minutes.

A Tiny Javascript Framework for Common Validation Scenarios.[^]
 
Share this answer
 
Try using RegularExpressionValidator, put this in your Control validationexpression="^[0-9]{4}$"
 
Share this answer
 
By using javascript we can restrict characters in integer text box and integers in character text box.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900