Restrict minus(-) in mobile view RRS feed

  • Question

  • User-257070954 posted

    Hi all,

           In my application i am using dynamically created number textbox. in computer its working as expected its allowing to enter only numerical values. But when i check in mobile its allowing to enter -(minus). How we can stop entering minus in number textbox in mobile view. i tried below code also.but not working

       $('#divListProduct').on('keypress', 'input[type="number"]', function () {
           $(this).val($(this).val().replace(/[^\d].+/, ""));
            if ((event.which < 48 || event.which > 57)) {
                $("#divMessage").html("Please enter numerical values in qty")
            this.value = this.value.replace(/[^0-9\.]/g, '');

    Tuesday, August 4, 2020 9:46 AM

All replies

  • User-474980206 posted

    The global event object is IE only. Mobile browsers are html 5 compliant generally, and don’t have a global event. It should be a parameter of the handler. See jquery event handling docs.

    Tuesday, August 4, 2020 2:54 PM