0
votes

I been used to do validation using knockout validation plugin and all of a sudden i am facing a issue i am unable to get rid of .

Html onLoad :

<input class="form-control" type="text" data-bind="value:$data.Name"/>
<span class="required" style="display: none;"></span>
<span class="required" style="display: none;"></span>

ViewModel:

function details() {
    var self =this;
    self.Name = ko.observable("");
    self.Validation = ko.validatedObservable([
        self.Name.extend({ number: true })
    ]);
}

When i removed self.Name.extend i get no span tags onLoad but if i keep it then i get two span tags and because of that i get same error messages displaying twice under control like this field is required & this field is required .

I also debugged and checked the function is excecuting only once .

I refered this but i can't fix my issue .

I hope someone can show light on this issue .

1

1 Answers

3
votes

Credits to Hsakarp as he posted a valuable comment here

One of my partail page is referred with knockout validation.js and i am had same validation file in my main layout page . I have't noticed the script file added by my colleague .

Finally , i tried to see View Source then i came to see clearly there are two knockout validation script files referred of same kind . so i removed one of those which is included in partial view which got my issue fixed .