Skip to content

valid() does not return boolean value #109

@fredyang

Description

@fredyang

for some reason I need to write a function that return whether it a element is valid, only it return false value, I will do something

function x() {
        return $( this ).valid();
} 

var y = x();
// I can not write , if (!y) {} , with my reason
if (y === false) {
}

and I got a supprise the valid does not return a false value, but a falsy value 0, I check the valid() method, I found that it use bitwise & operator, but not logic && operator, I think this is bug, although, I can rewrite my function

function x() {
        return !!$( this ).valid();
} 

I think the statement in valid() function should be

valid = valid && validator.element(this);

instead of

valid &= validator.element(this);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions