Top Ad unit 728 × 90

Allow hyphen and floating numbers in keypress event in jquery

If you want to bind the textbox only takes input the numbers, dot, hyphen means minus sign then you can use this function. This script is already tested and works fine.



$('input.numbers').keypress(function(event) {
           if (event.which != 46 && event.which != 45 && event.which > 31
           && (event.which < 48 || event.which > 57))
           return false;

           if(event.which == 46
           && $(this).val().indexOf('.') != -1) {
                event.preventDefault();
        }
  });



It will take only one dot(.). Sometimes developer forgets to add left arrow, right arrow, backspace and delete key. So, don't worry about it. Just try the above script. It may resolve your problems. If it works for you then just give comments. Thanks!
Allow hyphen and floating numbers in keypress event in jquery Reviewed by Ashok Sen on 09:32:00 Rating: 5

3 comments:

Anonymous said...

Online Casino » Best Slots Casinos For Real Money 2021
The Online Casino Review. The best online slots casinos 2021. BEST 바카라 You may play for free with 출장안마 the best bonuses, 코인카지노 회원가입 promotions,  출장샵 Rating: 5 · 카지노 ‎Review by CasinoWow

Up4pc said...



Extremely useful information which you have shared here. This is a great way to enhance knowledge for us, and also helpful for us. Thankful to you for sharing an article like this.
Idle Arrows (gold coins) Crack

Up4pc said...



Extremely useful information which you have shared here. This is a great way to enhance knowledge for us, and also helpful for us. Thankful to you for sharing an article like this.
Idle Arrows (gold coins) Crack

Website Design Company at Kolkata All Rights Reserved © 2014 - 2019
Developed by Asenwebmedia

Contact Form

Name

Email *

Message *

Powered by Blogger.