Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Only Numeric value with dot can be enter in text box

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 373
    Comment on it

    If you need only float or numeric value to be enter in the text box. You can use the below code.

    <input name="score" id="score" type="text">
    
    <script>
    
    $(document).ready(function() {
        $("#score").keydown(function(event) {
            //alert(event.keyCode);
              // Allow only backspace, delete, dot, arrow key and numeric value 
            if ((event.keyCode > 95 && event.keyCode < 106) || (event.keyCode > 47 && event.keyCode < 58) || (event.keyCode == 190 || event.keyCode == 110 || event.keyCode == 8 || event.keyCode == 46 || event.keyCode == 37 || event.keyCode == 39))   {
                // let it happen, don't do anything
            }
            else {          // Ensure that it is a number and stop the keypress
    
                    event.preventDefault(); 
    
            }
        });
    });
    
    </script>
    

    NOTE :: This text box will allow only numeric or float value, if you enter any alphabetic key or special character it will not be accepted.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: