dfmmalaw
6/26/2017 - 4:46 PM

Clear data from form fields on modal when closed and clearing validation message

Clear data from form fields on modal when closed and clearing validation message

var vm = {
    clearModal: clearModal
};

function clearModal() {
    validationDialog.hideAndReset();
    VendorName(null);
    SendNotificationsViaApi(false);
    StandardApiEndpoint(null);
    OutboundUsername(null);
    OutboundPassword(null);
    SendInvite(false);
    Seamless(false);
    DateDosSigned(null);
    TestDetailsProvided(null);
    CompleteDate(null);
    InactiveDate(null);
    CertificateRequirements(false);
    ko.validation.group(vm, { deep: true }).showAllMessages(false);
}
<div class="row">
    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <button id="btnAdd" class="btn btn-primary" data-bind="click: clearModal" data-toggle="modal" data-target="#apiVendorModal">Add New Vendor</button>
    </div>
</div>