Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Auto Spacer for input boxes
- Written by: Alex Kovacs
- */
- // Input box
- console.log("Loaded!");
- let monogram_input = document.querySelector('input.pplr_monogram');
- // Add event listener
- monogram_input.addEventListener('input', function(e) {
- console.log("Input");
- // Get string and split it.
- let string = e.target.value.split(" ").join("");
- // If the string exists
- if (string.length > 0) {
- console.log("Input exists");
- // Set whitespace to every other character and then join it
- string = string.match(new RegExp('.{1,1}', 'g')).join(" ");
- }
- // Set the value of the targer
- e.target.value = string;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement