Closed aenany-atmosphereiot closed 5 years ago
Have a look at the 'Form with Auto Focus on Invalid Field' example at: http://alpacajs.org/docs/api/forms.html
I think the problem is you need to first call 'refreshValidationState()' before checking 'isValid()'. I solved this by implementing a jQuery promis. Making sure to wait until the form validation was refreshed before checking the validation state:
$.when(this.refreshValidationState(true)).then(function () { if (form.isValid()) {
Hey. If you add the "form" property to the "options" property in the JSON you use to initialize an instance of alpaca, you can interrogate that form property once initialized in order to run [yourAlpacaInstance].form.isFormValid(). It's odd that you have to manually add the "form" property in order to use this API method but I'll leave an example below.
formData.postRender = function(control) { alpacaInstance = control;
formValid = alpacaInstance.form ? alpacaInstance.form.isFormValid() : true;
Hello Alpaca Team,
Any idea how to get the current validation state of an alpaca form? I have a webpage with multiple alpaca forms and a single submit button. And I want to check that all forms are valid before the data is collected from all the forms and submitted.
$('#alpacaContainer1').alpaca('get').isValid() $('#alpacaContainer2').alpaca('get').isValid() $('#alpacaContainer3').alpaca('get').isValid()
The aforementioned calls seem to return true even if the inputs are invalid. Is there another function I should be calling to get the actual validation state?
Thanks!