1000hz / bootstrap-validator

A user-friendly HTML5 form validation jQuery plugin for Bootstrap 3
http://1000hz.github.io/bootstrap-validator
MIT License
2.38k stars 1.07k forks source link

how to synchronously tell form is valid from js #116

Open ptica opened 9 years ago

ptica commented 9 years ago

69 mentions

var hasErrors = $('#booking').validator('validate').has('.has-error').length;
if (hasErrors) { fail here }

this does not work if you are quick enough and create an invalid field just before invoking validator('validate') which returns immediately with old still valid jQuery content and invalidation happens only after that in a callback.

(add a data-remote if you need more time)

macedd commented 9 years ago

Yah, for sure!

validate trigger an event on each field, which is an async call.

macedd commented 9 years ago

So, what we are saying is on the onSubmit method It is currently buggy, and may be working just for the isIncomplete call.