locked
validation not works when open website in mobile? RRS feed

  • Question

  • User-1647172364 posted

    Hlo Professionals!

    I am having one textbox in my webpage for  mobile no.  now i  added validation that only numbers can be input in textbox but when i open my website in laptop  validation works perfectly and when i open my website in mobile alphabets numbers also get inputed. 

    My requirement is when i open website in mobile then also alphabets characters will be ignored. 

      Here is my code pls execute it.

      
     <div class="row">
    
    <center>
    
    
      
        <input type = "text"   id = "Txtstyle2" placeholder="Enter Your REAL Phone No. Here..."  required="required"  onkeypress="isInputNumber(event)" />
        <script>
                
                function isInputNumber(evt){
                    
                    var ch = String.fromCharCode(evt.which);
                    
                    if(!(/[0-9]/.test(ch))){
                        evt.preventDefault();
                    }
                    
                }
                
            </script>
       
       </center>
        </div>
    

    Thursday, August 20, 2020 6:48 PM

All replies