Disabling the submit button before verification

Is there a way to use dojo / dijit to disable the submit button until all fields on the form are valid. As if you have dojo > method > onChange inside the form? Thus, the submit button is enabled only when all form elements meet their criteria?

+4
source share
2 answers

Do you dijit.form.Form widget as your form? If so, I suggest connecting to the Form event onValidStateChange . The docs for this event specifically indicate your use case:

 onValidStateChange Defined by dijit.form._FormMixin Stub function to connect to if you want to do something (like disable/enable a submit button) when the valid state changes on the form as a whole. Deprecated. Will be removed in 2.0. Use watch("state", ...) instead. 

The best way to see which events are available for a given widget is to look at the API Documentation for the widget that interests you in the "Event Summary" heading. The dojocampus reference documentation often does not contain examples of links to some of the more obscure widget features.

+2
source

I suggest having a hidden button that will submit the form. When you click the visbile button, run the javascript function, which checks all the input and then clicks on the hidden button to submit the form. Please find the pseudo code below

  <form action="register"> <input dojoType="dijit.validation.TextBox"/> <button onClick="validateall()">submit</button> <button id="submitForm" type="submit" hidden="true"/> </form> function validateAll(){ if(AllOk){ clearErrorMessage(); dojo.byId('submitForm').click(); }else{ showErrorMessage(); } 
0
source

All Articles