KO binding is not working in IE10 and IE11

2.7k views Asked by At

Here is my data-bind

<input type='text' data-bind="value: duration" id="duration" />

And I have custom javascript code to prevent user from submitting non-numeric text for "duration" which fires on keyup event for duration field. This is working fine in chrome, firefox, and IE9. But not working in case of IE10 and IE11

Here is my script

$(document).on('keyup', '#duration', function () {
        var textvalue = this.value.replace(/[^0-9\.]/g, '');
        this.value = !textvalue ? '' : parseInt(textvalue, 10);
    });

Regards

1

There are 1 answers

0
csharpsql On

I know that this is a an old post now but in case other people come across this I had a similar issue today and discovered that there is another ko binding for text input called textInput. I would suggest using that instead. The textInput binding updates immediately as well as working fine for me in IE11.

http://knockoutjs.com/documentation/textinput-binding.html

<input type="text" data-bind="textInput: name" />

Also, jQuery has a nice numeric plugin for numeric inputs.

https://www.nuget.org/packages/jQuery.Numeric/