Skip to Content
NFSFU234FormValidation v3 is here — file upload validation, config-driven rules, and more.
v3 (current)available-functions

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

FunctionTypeDescription
autoInit()StaticScans 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)StaticRegister 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

FunctionTypeDescription
submit(userOptions?, callback?)InstanceValidates 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?)InstanceValidates the whole form (every input, textarea, select, radio, checkbox, and file field) without submitting it.

Field Validation

FunctionTypeDescription
validateAllCheckbox(form, options)InstanceValidates every checkbox in the form.
validateAllFile(form, options?)InstanceValidates every <input type="file"> field in the form. Async - see validateFile.
validateAllInput(form, customErrorMessages)InstanceValidates every input in the form. Returns true, or an array of per-field error results.
validateAllRadio(form, customErrorMessage)InstanceValidates every radio group in the form.
validateAllSelect(form, options)InstanceValidates every <select> field in the form.
validateAllTextarea(form, options)InstanceValidates every <textarea> field in the form.
validateCheckbox(checkboxInputField, options?)InstanceValidates a single checkbox field.
validateFile(fileInputField, options?)InstanceValidates 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?)InstanceValidates a single input field, via its HTML attributes or an explicit options override.
validateRadio(radioInputField, customErrorMessage?)InstanceValidates a single radio group by its input name.
validateSelect(selectField, options, callback)InstanceValidates a single <select> field.
validateTextarea(textareaField, options)InstanceValidates a single <textarea> field.

Format & Type Checks

FunctionTypeDescription
checkVariableType(variable)InstanceReturns the runtime type of a variable as a lowercase string (e.g. 'string', 'number', 'object', 'function'), more granular than a raw typeof.
containsOnlyIntegers(str)InstanceChecks whether a string consists only of integer digits.
countString(string)InstanceCounts the number of characters in a string.
isEmail(email)InstanceChecks whether a string is a syntactically valid email address.
isNumber(number)InstanceChecks whether a value is numeric.
isOnline()InstanceChecks whether the browser is currently connected to the internet.
isURL(url)InstanceChecks whether a string is a syntactically valid URL.
isZip(zipCode)InstanceAlias for isZipCode.
isZipCode(zipCode)InstanceChecks whether a value is a syntactically valid ZIP/postal code.

Password Utilities

FunctionTypeDescription
checkPassword(password, minLength?, maxLength?, includeSymbolsCheck?, userSymbolRegex?)InstanceValidates a password against length and (optionally) symbol requirements.
generatePassword(length?, shouldHash?)InstanceGenerates a random password of the given length.
generateRandomPassword(length, shouldHash)InstanceAlias for generatePassword.
getPasswordStrength(password)InstanceAlias for passwordStrength.
passwordStrength(password)InstanceScores 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?)InstanceToggles a single password field between masked and visible, swapping an optional show/hide icon accordingly.
togglePasswordVisibilityAll(icons, uform?, toggleAll?)InstanceToggles every password field in a form (or just one, unless toggleAll is set) between masked and visible.

Form & Request Utilities

FunctionTypeDescription
ajax(AJAXOptions)StaticSends 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)InstanceInstance 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)InstanceManually displays an error message, either inline next to a field or as a modal, using the same rendering path validation errors use internally.
getAJAXResponse()InstanceReturns 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)InstanceReads 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()InstanceGets the current page’s URL.
loading(message, submitBtn?, form?)InstanceShows 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?)InstanceRedirects the browser to a URL, optionally after a delay.
reset(u_form)InstanceResets all fields in a form to their default/empty values.
restrictInputWithCounter(inputElement, counterContainer, options?)InstanceWires a live character counter to an input/textarea, and (depending on options) restricts further input once the limit is reached.
Last updated on