I have a view model that has the observable "yearsOld" which is bound to an html input.
<input type="text" data-bind="value:yearsOld">
var viewModel = {
yearsOld: ko.observable("");
}
Is there any way to add a css class to the input from the viewModel? The reason I'm asking is because I need to add a css class named "positive-integer" to the input bound to yearsOld so that my 3rd party jQuery library will restrict non-numeric input on that bound input field.
Note: I'm aware of the css binding that knockout provides to place on a input field, but that doesn't help me here since the css is not necessarily dynamic. I'm just hoping to be able to put a css class on the input from the viewModel instead of putting it directly on each individual input. Even if this doesn't make sense to you, I'm just curious if it is possible.