Im trying to create a custom binding to show hint texts in text inputs.
so far I have this but it doesnt work:
ko.bindingHandlers.hintText= {
init: function (element, valueAccessor) {
element.focus(function () {
if ($(this).val() === defaultText) {
$(this).attr("value", "");
}
});
element.blur(function () {
if ($(this).val() === '') {
$(this).val(valueAccessor());
}
});
}
}
the html:
<input id="profileID" type="text" data-bind="hintText:'Enter Profile ID'" />