= 48 && event.charCode <= 57 "to...">

OnClick javascript event not working on mobile device

On my JSP page, I use onkeypress="return event.charCode >= 48 && event.charCode <= 57 "to only allow numbers. It works great with website browsers. Well, it is not supported in the mobile browser (Google chrome). I have included javascript to execute. I tried this answer but nothing happens. I have another problem that will calculate value in input tagif the value is above 4999, it will display a different input tag, also does not work on the mobile device. How can i solve this?

Here is the code

The first button to enter values ​​that accepts only numerical values

<input type="text" name="amount1" id="upload" onkeypress="return event.charCode >= 48 && event.charCode <= 57 && showFile()" required />

Hidden button displayed above 4999

<div id='openfile' style='display:none'><input type="file" class="form-control" name="panImg1" placeholder="Upload Your pancard image"  /></div>

Script file

<script type="text/javascript">
        function showFile()
        {
            var choice = document.getElementById('upload').value;
            if (choice > 4999)
            {
                document.getElementById('openfile').style.display = 'block';
            } else
            {
                document.getElementById('openfile').style.display = 'none';
            }
        }
    </script>
0
source share
2

, javascript onKeypress - Google Chrome Chrome, , jquery , $(document).ready(function () { $("#upload").on('input', function () { if (v > 40000) {
var v = "var v = "<div id='appDiv' class='col-md-4 inputGroupContainer'><input required='' type='text' name='panImg1' /></div>"; $('#newDiv').append(v); } }); });

​​ Div <div id="newDiv"></div>. jquery . .

0

Google Chrome Mobile ..

onkeyup="mobilePress(e)"
function mobilePress(e) {
    e.target.value = e.target.value.replace(/[^\d]/g, '');
    return false;
}

"textInput" RegExp. , ?

+1

Source: https://habr.com/ru/post/1685840/


All Articles