0

So I've been working with FluentUI and I've setup a TextField with a onError Property which fires but it only fires when starting the app up. When changing the value the error does not fire again.

I've followed the FluentUI docs but I cannot replicate what they did somehow.

Would be nice to get some help.


const ControlledTextField = (props:any):JSX.Element => {
const getErrorMessage = (value: string): string => {
    console.log(value);
    return value.length > 0 && value.length < 3
      ? ""
      : `Input value length must be less than 3. Actual length is ${value.length}.`;
  };

return (
<TextField label="String-based validation" onGetErrorMessage={getErrorMessage} />
);

https://codesandbox.io/s/shy-worker-wlxhfw?file=/src/App.tsx:1095-1198

  • Hi Them Han and welcome to SO. :) Well explained answer is here with Codepen working solution: https://stackoverflow.com/questions/68013169/ongeterrormessage-not-being-called-for-fluentuireact-textfield/68090258#68090258 – Marko Savic May 17 '22 at 18:17
  • 1
    Does this answer your question? [onGetErrorMessage not being called for FluentUIReact TextField](https://stackoverflow.com/questions/68013169/ongeterrormessage-not-being-called-for-fluentuireact-textfield) – Marko Savic May 17 '22 at 18:19

0 Answers0