Why does the .keyup () page refresh start?

I have this function:

$('.PhoneNumbers').on('keyup focusout', $('input:text[name^="Customers[0].PhoneNumbers"]'), function (e) {
    phoneRadioBtns(e);
});

The problem is that when I refresh the page, it fires the keyup event and performs this function, which is not the desired result. Does anyone know how to fix this?

+3
source share
1 answer

Does this only happen when you press F5 while inside the input?

(This was the only way I was able to reproduce: try here http://jsfiddle.net/ybuTv/ )

One way to solve this problem is to exclude the F5 button from the event: http://jsfiddle.net/ybuTv/1/

$(function() {
    $('.PhoneNumbers').on('keyup focusout', $('input:text[name^="Customers[0].PhoneNumbers"]'), function(e) {
        if(e.which!=116){
            phoneRadioBtns(e);
        }
    });

});
+1
source

All Articles