forum

Home / DeveloperSection / Forums / how to call a function on textchange in textfield using java script

how to call a function on textchange in textfield using java script

Anonymous User226604-Apr-2013
Hi Mindstickians!

I have textfiedl on which i am calling a function which is given below but problem is that it is working on enter but not working on keyup or as the value 

of textfield changes i want to call this method.

Javascript:

$(function() {

    var input = $('.input'),
        bar = $('.bar'),
        bw = bar.width(),
        percent = bar.find('.percent'),
        ps = percent.find('span');

    input.on('keydown', function(e) {
        if (e.keyCode == 13) {
            var t = $(this),
                val = t.val();
            if (val >= 0 && val <= 100) {
                var w = 100 - val,
                    pw = (bw * w) / 100,
                    pa = {
                        height: w + '%'
                    },
                    cw = (bw - pw) / 2,
                    ca = {
                        left: cw
                    }
                ps.animate(pa);
                cs.text(val + '%');
                circle.animate(ca, function () {
                    circle.removeClass(name)
                }).addClass(name);
            } else {
                alert('range: 0 - 100');
                t.val('');
            }
        }
    });

});
Html:

<div class="text">
    <input type="text" class="input" value="0" id="sliderValue170h" />
</div>

Thank in advance!

Updated on 04-Apr-2013
I am a content writter !

Can you answer this question?


Answer

2 Answers

Liked By