JSFiddle - React, Tailwind, and code Playground

http://stackoverflow.com/questions/14590759/how-to-wrap-a-django-form-wizard-in-a-view/14590823

by bikeshedder

HTML

<p>
    <input type='checkbox' data-bind="checked: hasCellphone" />
    I have a cellphone
</p>

<p>
    Your cellphone number:
    <input type='text' name='cell' data-bind="value: cellphoneNumber, valueUpdate: 'afterkeydown', enable: hasCellphone" />
</p>

<button data-bind="enable: cellphoneNumberValid">Do something</button>

JavaScript

function parseAreaCode(s) {
    // just a dummy implementation
    return s.substr(0, 3);
}

function AppViewModel() {   
    this.hasCellphone = ko.observable(false);
    this.cellphoneNumber = ko.observable("");
    this.cellphoneNumberValid = ko.computed(function() {
        return parseAreaCode(this.cellphoneNumber()) != '555';
    }, this);
}

ko.applyBindings(new AppViewModel());