How to properly validate input values with React.JS?

前端 未结 9 1097
孤城傲影
孤城傲影 2020-12-22 19:07

I have a simple form. All of the components and state are held in the Page component. There are 2 display headers and 3 input fields. The first input is supposed to be text,

9条回答
  •  旧时难觅i
    2020-12-22 19:57

    I have written This library which allows you to wrap your form element components, and lets you define your validators in the format :-

     !validator.isEmpty(val),
                 errorMessage: "Cannot be left empty"
                },...
            }]}>
                {
                              console.log("you have typed: ", evt.target.value);
                            }
                           }/>
    
    

提交回复
热议问题