Skip to Content
NFSFU234FormValidation v3 is here — file upload validation, config-driven rules, and more.

loading

Shows a loading message/animation on a submit button (or the form itself) while an async operation - typically .submit() - is in flight. Pair with your own logic to clear it once the operation settles. Returns: boolean \| ErrorMessageInterface

ParameterTypeRequiredDefaultDescription
messagestringrequired-The loading text to display.
submitBtn`null \string \HTMLElement`optional
form`undefined \null \string \HTMLElement`
Usage
Example: Update Button Content with Loading Message
const formElement = document.getElementById('myFormId'); nfsfu234FormValidation.loading('Loading...', formElement.querySelector("button[type=submit]"));
Example Form HTML
<form id="myFormId"> <input type="text" name="fieldName1" value="value1" data-attr-name="fieldName1" /> <input type="text" name="fieldName2" value="value2" data-attr-name="fieldName2" /> <button type="submit">Submit</button> </form>
JavaScript to Update Button Content
const formElement = document.getElementById('myFormId'); const buttonElement = formElement.querySelector("button[type=submit]"); nfsfu234FormValidation.loading('Loading...', buttonElement);
Expected Output

The content of the submit button within the form will be updated to display the message “Loading…”.

Last updated on