cferdinandi / validate

A lightweight form validation script.
MIT License
230 stars 39 forks source link

Validate form API doesn't return boolean #22

Closed Sumit-Chakole closed 7 years ago

Sumit-Chakole commented 7 years ago

No api to validate complete form, return boolean if form looks good or if form has error show all of them.

cferdinandi commented 7 years ago

Can you please rephrase this issue? I don't understand what you mean.

cferdinandi commented 7 years ago

Closing due to non-responsiveness

sntran commented 7 years ago

I think he means adding polyfill for HTMLFormElement.checkValidity():

Returns true if the element's child controls are subject to constraint validation and satisfy those contraints; returns false if some controls do not satisfy their constraints. Fires an event named invalid at any control that does not satisfy its constraints; such controls are considered invalid if the event is not canceled. It is up to the programmer to decide how to respond to false.

I would love to have this as well.

cferdinandi commented 7 years ago

checkValidity is pointless. It does the same thing as HTMLFormElement.validity, but provides you with no additional information.

cferdinandi commented 7 years ago

See PPK's piece on native form validation for more details on what I mean.

sntran commented 7 years ago

The importance part of checkValidity, at least to me, is the invalid event that fires from it that can be cancelled.

Also, input elements can also have this function too. The "invalid" event allows us to handle error display elsewhere when needed.

cferdinandi commented 7 years ago

Put another way: beyond the scope of this project. There are some other projects that provide broader polyfilling.

sntran commented 7 years ago

I'll respect that.