nfsfu234-form-validation
Version:
NFSFU234FormValidation is a lightweight and user-friendly JavaScript library designed for validating HTML form elements, with a special emphasis on textarea fields. It offers customizable validation messages, comprehensive support for required field check
81 lines (78 loc) • 4.78 kB
TypeScript
interface ErrorMessageInterface {
message?: string | boolean | number;
type?: string;
code?: number;
data?: string | number | object | Array<any> | JSON | HTMLElement | null | undefined | boolean;
}
declare class NFSFU234FormValidation {
private AJAXResult;
form: HTMLFormElement | HTMLDivElement | undefined;
customErrorMessages: {
[key: string]: string;
};
constructor(formDetails?: any, AJAXOptions?: any);
private populateOptionsVariables;
submit(userOptions?: HTMLFormElement | HTMLDivElement | string | {
form: string | HTMLFormElement | HTMLDivElement;
customErrorMessages?: {
[key: string]: string;
};
}, callback?: any): boolean | Promise<any>;
validate(userOptions?: HTMLFormElement | HTMLDivElement | string | {
form: HTMLFormElement | HTMLDivElement | string;
customErrorMessages?: any[];
}, callback?: any): boolean | Promise<any>;
/**
* ajax
*/
ajax(AJAXOptions: any): Promise<any>;
/**
* getAJAXResponse
*
* This function retrieves the AJAX response that was stored in the global variable `AJAXResult`.
* It returns the AJAX response if available or false if no response is found.
*
* @returns {Promise|boolean} - Returns the AJAX response (a Promise) if available; otherwise, returns false.
*/
getAJAXResponse(): Promise<any> | boolean;
getFormDetails(form: HTMLFormElement | HTMLDivElement | string): boolean | ErrorMessageInterface | Record<string, string | boolean>;
loading(message: string, submitBtn?: string | HTMLElement | null, form?: string | HTMLElement | null | undefined): boolean | ErrorMessageInterface;
displayError(details: any): void;
isEmail(email: string): boolean;
isURL(url: string): boolean;
isNumber(number: string | number): boolean;
isZipCode(zipCode: string | number): boolean;
isZip(zipCode: string | number): boolean;
countString(string: string): number;
generatePassword(length?: number, shouldHash?: boolean): Promise<any>;
generateRandomPassword(length: number, shouldHash: boolean): Promise<any>;
passwordStrength(): void;
getPasswordStrength(): void;
checkPassword(password: string, minLength?: number, maxLength?: number, includeSymbolsCheck?: boolean, userSymbolRegex?: RegExp | string): string | boolean;
verifyPassword(stringPassword: string, hashedPassword: string, isHashed?: boolean): Promise<boolean>;
passwordMatch(stringPassword: string, hashedPassword: string, isHashed?: boolean): Promise<boolean>;
hashPassword(password: string): Promise<string | false>;
togglePasswordVisibility(input: HTMLInputElement, showIcon?: string | HTMLElement | null, hideIcon?: string | HTMLElement | null): any;
togglePasswordVisibilityAll(icons: {
show: string | HTMLElement | null;
hide: string | HTMLElement | null;
}, uform?: string | HTMLFormElement | HTMLDivElement | null, toggleAll?: boolean): void;
validateInput(inputField: HTMLInputElement | string, options?: any, callback?: any): true | Promise<unknown>;
validateAllInput(form: HTMLFormElement | HTMLDivElement | string, customErrorMessages: any): boolean | ErrorMessageInterface[];
validateRadio(radioInputField: HTMLInputElement | string, customErrorMessage?: any): string | boolean | ErrorMessageInterface;
validateAllRadio(form: HTMLFormElement | HTMLDivElement, customErrorMessage: any): boolean | ErrorMessageInterface | ErrorMessageInterface[];
validateCheckbox(checkboxInputField: HTMLInputElement, options?: any): boolean | ErrorMessageInterface;
validateAllCheckbox(form: HTMLFormElement | HTMLDivElement, options: any): boolean | ErrorMessageInterface | ErrorMessageInterface[];
validateSelect(selectField: HTMLSelectElement, options: any, callback: any): boolean | ErrorMessageInterface;
validateAllSelect(form: HTMLFormElement | HTMLDivElement, options: any): boolean | ErrorMessageInterface | ErrorMessageInterface[];
validateTextarea(textareaField: HTMLTextAreaElement, options: any): string | boolean | ErrorMessageInterface;
validateAllTextarea(form: HTMLFormElement | HTMLDivElement, options: any): boolean | ErrorMessageInterface | ErrorMessageInterface[];
restrictInputWithCounter(inputElement: HTMLInputElement | HTMLTextAreaElement, counterContainer: HTMLElement, options?: any): any;
containsOnlyIntegers(str: string): boolean;
getPageURL(): string | boolean;
redirect(url?: string | null | false | undefined, delay?: number): void;
checkVariableType(variable: any): string;
isOnline(): boolean;
reset(u_form: HTMLFormElement | HTMLDivElement | string): boolean;
}
export { NFSFU234FormValidation as default };