Automation of part of the



  • We need to get into the text field. http://vk.com/id2 automatically removed http://vk.com/leaving only what was printed after http://vk.com/
    How do you do that?



    1. Added <input>- the processor's losing the trick.
    2. In the processor, we're looking for the necessary line in the contents <input>- Yeah.
    3. If the required line is present at the beginning of the contents, we shall remove it from the contents. <input>- Yeah.

    With jQuery:

    $(function() {
        var checkString = "http://vk.com/";
        var $input = $('#input');
        $input.on("blur", function() {
            var value = $input.val();
            var place = value.indexOf(checkString);
            if (place == 0) {
                value = value.substr(checkString.length);
                $input.val(value);
            }
        });
    });
    <input id="input" />
    

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

    Same without jQuery:

    document.addEventListener("DOMContentLoaded", function() {
    var checkString = "http://vk.com/";
    var input = document.getElementById('input');
    input.addEventListener("blur", function() {
    var value = input.value;
    var place = value.indexOf(checkString);
    if (place == 0) {
    value = value.substr(checkString.length);
    input.value = value;
    }
    });
    });
    <input id="input" />




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2