Wednesday, April 15, 2015

Jquery CHECKS IF THE KEY PRESSED IS A NUMERIC OR DECIMAL VALUE

  function isNumber(evt, element) {

            var charCode = (evt.which) ? evt.which : event.keyCode

            if (
                (charCode != 45 || $(element).val().indexOf('-') != -1) &&      // “-” CHECK MINUS, AND ONLY ONE.
                (charCode != 46 || $(element).val().indexOf('.') != -1) &&      // “.” CHECK DOT, AND ONLY ONE.
                (charCode < 48 || charCode > 57))
                return false;

            return true;
        }

  $('input[id$=txefetAmount],input[id$=txtsdfAmount],input[id$=txtsdAmount]').keypress(function (event) {

            return isNumber(event, this)

        });

No comments:

Post a Comment