Wednesday 2 January 2013

JQuery Input text box Numeric Validation Integer and Decimal



///////////////////////////////////////IntegerValidation ///////////////////////////////////////////////////////
            $("#txtRequestedDays").keyup(function (e) {
                if (/\D/g.test(this.value)) {
                    // Filter non-digits from input value.
                    this.value = this.value.replace(/\D/g, '');
                }
            });


///////////////////////////////////////Decimal Validation ///////////////////////////////////////////////////////
            $("#txtRequestedDays").keyup(function () {
                if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
                    this.value = this.value.replace(/[^0-9\.]/g, '');
                }
            });