Available Functions
Every public method and static function, grouped by category. Click through to any function for full parameter details and usage examples.
Static Methods
| Function | Type | Description |
|---|---|---|
autoInit() | Static | Scans the current page for whichever registered forms are present and wires each one up (novalidate, submit handling, and AJAX submission if configured). Call this once per page, after configureForms() has been called with the site’s full form config. |
configureForms(configs) | Static | Register form configs for the whole site in one place - typically a single shared config file included on every page. Only forms actually present in the current page’s DOM get wired up when autoInit() runs, so it’s safe to register every form on the site. |
Core
| Function | Type | Description |
|---|---|---|
submit(userOptions?, callback?) | Instance | Validates the whole form (every input, textarea, select, radio, checkbox, and file field), then—if validation succeeds and AJAX is enabled—submits the form using either the supplied AJAX options or the instance’s default AJAX configuration. The method first resolves the target form from the supplied userOptions (or falls back to the form attached to this instance), validates it, and finally submits it if appropriate. Validation-only usage is also supported. When AJAX is not enabled, the method simply resolves with the validation result. |
validate(userOptions?, callback?) | Instance | Validates the whole form (every input, textarea, select, radio, checkbox, and file field) without submitting it. |
Field Validation
| Function | Type | Description |
|---|---|---|
validateAllCheckbox(form, options) | Instance | Validates every checkbox in the form. |
validateAllFile(form, options?) | Instance | Validates every <input type="file"> field in the form. Async - see validateFile. |
validateAllInput(form, customErrorMessages) | Instance | Validates every input in the form. Returns true, or an array of per-field error results. |
validateAllRadio(form, customErrorMessage) | Instance | Validates every radio group in the form. |
validateAllSelect(form, options) | Instance | Validates every <select> field in the form. |
validateAllTextarea(form, options) | Instance | Validates every <textarea> field in the form. |
validateCheckbox(checkboxInputField, options?) | Instance | Validates a single checkbox field. |
validateFile(fileInputField, options?) | Instance | Validates a single <input type="file"> field: required/min/max file count, accepted types (accept), max size (maxSizeMB), and - for images - dimension limits. Async, since checking image dimensions requires decoding the file. |
validateInput(inputField, options?, callback?) | Instance | Validates a single input field, via its HTML attributes or an explicit options override. |
validateRadio(radioInputField, customErrorMessage?) | Instance | Validates a single radio group by its input name. |
validateSelect(selectField, options, callback) | Instance | Validates a single <select> field. |
validateTextarea(textareaField, options) | Instance | Validates a single <textarea> field. |
Format & Type Checks
| Function | Type | Description |
|---|---|---|
checkVariableType(variable) | Instance | Returns the runtime type of a variable as a lowercase string (e.g. 'string', 'number', 'object', 'function'), more granular than a raw typeof. |
containsOnlyIntegers(str) | Instance | Checks whether a string consists only of integer digits. |
countString(string) | Instance | Counts the number of characters in a string. |
isEmail(email) | Instance | Checks whether a string is a syntactically valid email address. |
isNumber(number) | Instance | Checks whether a value is numeric. |
isOnline() | Instance | Checks whether the browser is currently connected to the internet. |
isURL(url) | Instance | Checks whether a string is a syntactically valid URL. |
isZip(zipCode) | Instance | Alias for isZipCode. |
isZipCode(zipCode) | Instance | Checks whether a value is a syntactically valid ZIP/postal code. |
Password Utilities
| Function | Type | Description |
|---|---|---|
checkPassword(password, minLength?, maxLength?, includeSymbolsCheck?, userSymbolRegex?) | Instance | Validates a password against length and (optionally) symbol requirements. |
generatePassword(length?, shouldHash?) | Instance | Generates a random password of the given length. |
generateRandomPassword(length, shouldHash) | Instance | Alias for generatePassword. |
getPasswordStrength(password) | Instance | Alias for passwordStrength. |
passwordStrength(password) | Instance | Scores a password’s strength heuristically (length + character-class diversity), purely client-side - a UX strength meter, not a security guarantee. Returns a 0-100 score, a qualitative label, and suggestions. |
togglePasswordVisibility(input, showIcon?, hideIcon?) | Instance | Toggles a single password field between masked and visible, swapping an optional show/hide icon accordingly. |
togglePasswordVisibilityAll(icons, uform?, toggleAll?) | Instance | Toggles every password field in a form (or just one, unless toggleAll is set) between masked and visible. |
Form & Request Utilities
| Function | Type | Description |
|---|---|---|
ajax(AJAXOptions) | Static | Sends an AJAX request using the supplied request configuration. Sends an AJAX request using the supplied request configuration. Static - does not require a form or an instance. Use this when you only need the AJAX helper and don’t want to construct the class just to call it (e.g. NFSFU234FormValidation.ajax({...}) in a React component with no form to attach to). |
ajax(AJAXOptions) | Instance | Instance version of NFSFU234FormValidation.ajax. Sends an AJAX request using the supplied request configuration. The returned Promise is also stored internally so it can later be retrieved with (). |
displayError(details) | Instance | Manually displays an error message, either inline next to a field or as a modal, using the same rendering path validation errors use internally. |
getAJAXResponse() | Instance | Returns the Promise from the most recent AJAX request. This is useful if you need to access the result of an earlier call to () or () without creating a new request. |
getFormDetails(form) | Instance | Reads every field’s current value from a form - inputs, textareas, selects, checkboxes, and radios - keyed by field name (falling back to data-attr-name where name isn’t set). |
getPageURL() | Instance | Gets the current page’s URL. |
loading(message, submitBtn?, form?) | Instance | 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. |
redirect(url?, delay?) | Instance | Redirects the browser to a URL, optionally after a delay. |
reset(u_form) | Instance | Resets all fields in a form to their default/empty values. |
restrictInputWithCounter(inputElement, counterContainer, options?) | Instance | Wires a live character counter to an input/textarea, and (depending on options) restricts further input once the limit is reached. |
Last updated on