added all pages placeholders
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import React, { useState } from 'react';
|
||||
import './FormField.css';
|
||||
import React, { useState } from "react";
|
||||
import "./FormField.css";
|
||||
|
||||
|
||||
interface FormFieldProperties {
|
||||
type?: 'text' | 'email' | 'password' | 'number' | 'tel' | 'url' | 'search';
|
||||
type?: "text" | "email" | "password" | "number" | "tel" | "url" | "search";
|
||||
placeholder?: string;
|
||||
value: string;
|
||||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
@ -22,24 +22,24 @@ interface FormFieldProperties {
|
||||
|
||||
|
||||
const FormField: React.FC<FormFieldProperties> = ({
|
||||
type = 'text',
|
||||
type = "text",
|
||||
placeholder,
|
||||
value,
|
||||
onChange,
|
||||
required = false,
|
||||
errorMessage = 'Please fill out this field',
|
||||
errorMessage = "Please fill out this field",
|
||||
showError = false,
|
||||
onBlur,
|
||||
onFocus,
|
||||
className = '',
|
||||
className = "",
|
||||
disabled = false,
|
||||
autoComplete = 'off',
|
||||
autoComplete = "off",
|
||||
customValidator,
|
||||
showErrorInitially = false,
|
||||
icon: Icon,
|
||||
}) => {
|
||||
const [touched, setTouched] = useState<boolean>(showErrorInitially);
|
||||
const [customError, setCustomError] = useState<string>('');
|
||||
const [customError, setCustomError] = useState<string>("");
|
||||
|
||||
const validateField = (value: string): string => {
|
||||
if (required && !value) {
|
||||
@ -51,7 +51,7 @@ const FormField: React.FC<FormFieldProperties> = ({
|
||||
return customValidation;
|
||||
}
|
||||
}
|
||||
return '';
|
||||
return "";
|
||||
};
|
||||
|
||||
const shouldShowError = showError || (touched && validateField(value));
|
||||
@ -64,7 +64,7 @@ const FormField: React.FC<FormFieldProperties> = ({
|
||||
};
|
||||
|
||||
const handleFocus = (e: React.FocusEvent<HTMLInputElement>): void => {
|
||||
setCustomError('');
|
||||
setCustomError("");
|
||||
onFocus?.(e);
|
||||
};
|
||||
|
||||
@ -85,7 +85,7 @@ const FormField: React.FC<FormFieldProperties> = ({
|
||||
required={required}
|
||||
disabled={disabled}
|
||||
autoComplete={autoComplete}
|
||||
className={shouldShowError ? 'error' : ''}
|
||||
className={shouldShowError ? "error" : ""}
|
||||
/>
|
||||
{shouldShowError && (
|
||||
<div className="error-message">
|
||||
|
||||
Reference in New Issue
Block a user