How to disable textfield if textfield is empy

Topics: Code Checkins, General, Language Specification
Jul 15, 2014 at 8:44 PM
Hi everybody,

I have this:

@* Plaats *@
            <!-- ko foreach: woonplaats -->
            <br />
            <br />
            <div class="form-group" data-bind="validationHighlight: woonplaats">
                <label for="woonplaats" class="control-label col-sm-4 col-md-3 col-xl-2">
                    <!-- ko if: $index() === 0 -->

                <div class="col-sm-8 col-md-3 col-xl-4">
                    <input id="woonplaats" class="form-control" data-bind="value: woonplaats, disable:true" />
                    <!-- /ko -->

            <!-- /ko -->

and TypeScript:

private getPlaatsnaamPatient(plaatsnaam:string):string<PatiendDossierOverViewModel> {
        return plaatsnaam.toString.(plaatsnaam => new PatiendDossierOverViewModel(plaatsnaam));

So I have a textfield. and the value is from the database. But if there is no value in the textfield, then the textbox has to be disabled.

Thank you
Jul 16, 2014 at 6:18 PM
Edited Jul 16, 2014 at 6:19 PM
TypeScript does not do anything "magical". Figure out what you would do in JavaScript, then do it in TypeScript. Perhaps you would use var element = document.getElementById('woonplaats') in the event where data is received for the control, then enable/disable as needed, like element.disabled = !dataReceivedOk;.
Jul 18, 2014 at 4:39 PM
Thank you for you reply. I will try