0

I want to throw an error message when user types in '&' in a textbox and the rest other characters and special characters are allowed.

Below code snippet throws the error message when '&' is the last character of the string like 'hello&', but I want an expression to find '&' anywhere in the string.

comments: yup.string()  
  .matches(/[^&]+$/,  { message: 'error message', excludeEmptyString: true }),
Thulasi_G
  • 136
  • 2
  • 15

0 Answers0