There is a field:
<input id="box-1-form-input" type="text" name="box-1-form-input" placeholder="http://www." value="http://www." class="form-control"> It must be done so that it always defaults to " http: // www .". For myself, I identified 2 options:
Using a mask library by type ( https://github.com/RobinHerbots/Inputmask )
Manual filtering via regexp
In the first version I encounter a problem, since the mask needs to indicate the number of characters and as a result, the input field is " http: //www.___________________ ".
In the second version, I could not decide how to work with the input data without affecting my own mask (remove duplicate "http" and "www"). For example, sketched this code:
$("#box-1-form-input").on('change keyup input', function() { var input = $(this); if(~input.val().indexOf("http://www.")) { // regexp } else { input.val("http://www."); } }); What do you advise?
https://ru.stackoverflow.comwill you let him go, replacing the input onhttp://www.ru.stackoverflow.com? - Sergey