Sudarshan Sudarshan - 2 years ago 277
HTML Question

Convert value into lower case before knockout binding

Demo Here

I bound a label with knockoutjs. The value bound always should be in lower case. While it will remain in uppercase in js model. How to do this ?


var model = {



<label data-bind="text:name">

Answer Source

you just need to use toLowerCase in the view

view :

<div class='liveExample'>   
     <p> name: <label data-bind='text: name().toLowerCase()'></label></p> 

<b>Original Value:
<pre data-bind="text:ko.toJSON($data,null,2)"></pre>

sample working fiddle here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download