Skip to content

Commit

Permalink
invalid characters are unavailable for name fields (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtemHolikov authored Dec 4, 2024
1 parent cacc11a commit 2837e50
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/hooks/use-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,20 @@ export const useForm = <T extends object>({

const handleInputChange =
(key: keyof T) => (event: React.ChangeEvent<HTMLInputElement>) => {
const value =
const nameRegex = /[^a-zA-Z\u0400-\u04FF]/g

let value =
event.target.type === 'checkbox'
? event.target.checked
: event.target.value

if (
(key === 'firstName' || key === 'lastName') &&
typeof value === 'string'
) {
value = value.replace(nameRegex, '')
}

setData((prev) => {
const newData = {
...prev,
Expand Down

0 comments on commit 2837e50

Please sign in to comment.