How to add Html + js to Elementor Wordpress?

  • 0
    Good day, I'll tell you right away - the topic is completely zero.
    I want to add a password generator to my Elementor constructor using "HTML code". I insert a form and a script, but the script does not work, what am I doing wrong?

    THIS IS THE CODE:
    spoiler
    <form class="calc-form">
        <div class="calc-frow">
            <div class="calc-fleft">Длина пароля</div>
            <div class="calc-fright">
                <input type="number" step="1" pattern="\d*" name="length" class="calc-inp" style="width:60px; padding-right: 0;" min="1" max="32" value="8" maxlength="2">
            </div>
        </div>
        <div class="calc-frow">
            <div class="calc-fleft">Используемые символы</div>
            <div class="calc-fright">
                <div class="calc-input w150p">
                    <label><input type="checkbox" checked class="use_letters" /> Буквы</label>
                    &nbsp;&nbsp;&nbsp;<label><input type="checkbox" checked class="use_digits" /> Цифры</label>
                    &nbsp;&nbsp;&nbsp;<label><input type="checkbox"  class="use_symbols" /> Спец. символы</label>
                </div>
            </div>
        </div>
        <div class="calc-frow">
            <div class="calc-fleft">Пароль</div>
            <div class="calc-fright">
                <input type="text" id="result-password" class="calc-inp" style="width:300px;font-size: 10px;" />
            </div>
        </div>
    
        <div class="calc-frow button-row">
            <div class="calc-fright">
                <input type="button" class="calc-submit" value="Генерировать"  onclick="generatePassword()">
            </div>
        </div>
    
    </form>
    
    <script type="text/javascript">
        //<!--
        function generatePassword() {
            var letters = 'abcdefghijklmnopqrstuvwxyz'
            var digits = '0123456789'
            var symbols = '%*()[email protected]#$~'
            var str = ($('.use_letters').prop('checked') ? letters : '') + ($('.use_digits').prop('checked') ? digits : '') + ($('.use_symbols').prop('checked') ? symbols : '')
            var length = $('input[name=length]').val()
            var password = ''
            var next
            for (var i = 0; i < length; i++) {
                next = str[Math.floor(Math.random() * (str.length - 1 - 0 + 1)) + 0]
                password+= Math.round(Math.random()) ? next : next.toUpperCase()
            }
            var q = 1
            var int = setInterval(function() {
                if (q >= length) clearInterval(int)
                $('#result-password').val(password.substr(0,q))
                q++
            }, 35)
        }
    
        $(document).ready(function() {
    
            generatePassword()
    
            $('input[name=length]').blur(function() {
                if ($(this).val() > 32) {
                    $(this).val('32')
                }
            })
    
        })
            //-->
    </script>


    JavaScript Anonymous, Mar 19, 2019

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!