0

Tapping into the input field containing values, cursor should point at the end. It's actually browser's default behavior. But in iPhone and iPad, when user clicks on input border (upper border), cursor is appearing at the beginning of the input field. Below is a sample field in which I have tried couple of suggestions..but no luck.

<!DOCTYPE html>
<html>
<head>
    <meta name = "viewport" content = "width=device-width, initial-scale = 1 , maximum-scale=1, , maximum-scale = 1, user-scalable = 0">
    <script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>

    <script>
    $('document').ready(function(){
        $('input').focus(function(){
          this.selectionStart = this.selectionEnd = this.value.length;
          console.log("yp");
        });
    });
    </script>
    <style>
        body{
            font-size: 20px;
        }
        input{
            padding: 10px;
            font-size: 20px;
        }
    </style>
</head>
<body>


<form action="">
    <br>
    Username: <input type="text" name="usrname" value="Dipen" onfocus="this.value = this.value;">
    <br>
    <input type="submit" value="Submit">
</form>

</body>
</html>

Thanks in advance!!

Dipen Dedania
  • 1,452
  • 1
  • 21
  • 37

0 Answers0