haacked / aspnet-client-validation

A client validation library for ASP.NET MVC that does not require jQuery

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

0.5.3 - isFieldValid or validateForm causing error

dotnetshadow opened this issue · comments

Hi there,

I can't seem to get the isFieldValid or validateForm working properly

v.isFieldValid(document.getElementById('Name')) OR
v.validateForm(document.getElementById('form-trade'));

Uncaught TypeError: Cannot read properties of null (reading 'submitter')
    at e.shouldValidate (index.ts:631:31)
    at i (index.ts:654:23)
    at e.validateForm (index.ts:566:13)
    at e.isFieldValid (index.ts:617:22)
    at <anonymous>:1:3

If I use the false parameter it always returns false

v.isFieldValid(document.getElementById('Name'), false )

Am I doing something wrong?

UPDATE It seems to be happening on on v0.5.3. I tested with 0.5.1 for validateForm and it's ok.
My guess is, it has to do with the noformvalidate changes made between 0.5.1 and 0.5.3

UPDATE 2
Found the issue. Need to check if e is null. I'll see if I can write a patch for this

 e.prototype.shouldValidate = function(e) {
                    return !(e.submitter && e.submitter.formNoValidate)
}

A patch would be great! Thanks!