I added the knockout validation however it seems its throwing everything I put in the field: a,1,?, etc -- only thing works is having the field empty. I'm using the ko validation library and am extending it by using the pattern rule.
The ko template:
<script type="text/html" id="solutionRowTemplate">
<tr>
<td>
<input type="text" class="whole" data-bind="value: firstWhole, valueUpdate: 'afterkeydown'" />
</td>
</tr>
</script>
The ko viewmodel:
<script type="text/javascript">
var solutionData = @Html.Raw(new JavaScriptSerializer().Serialize(Model.SolutionList));
function SolutionModel(firstWhole) {
this.firstWhole = ko.observable(firstWhole);
}
var viewModel = {
solutions: ko.observableArray(ko.utils.arrayMap(solutionData, function (item) {
var model = new SolutionModel(item.FirstWhole);
model.firstWhole.extend({ pattern: '^[a-z0-9].$' });
return model;
})),
addSolution: function () {
this.solutions.push(new SolutionModel('', '', '', '', '', '', '', '', '', '', '', ''));
},
};
ko.applyBindings(viewModel);
</script>
Won't be surprised if its wrong on how I'm adding the extend...
Thanks, -rob