Skip to content
Advertisement

Converting Input Tag to Camel Case at Runtime

I am using React with Formik & Yup , currently I have a input field which is as f

JavaScript

I have the Yup logic as

JavaScript

which is working when I manually write it but my requirement is that if I write at run time only it should covert to Camel case

for Example

abhimanu singh -> Abhimanu Singh Abhi Raj -> Abhi Raj

Like this can anyone help me or guide me

Advertisement

Answer

You can convert the value to Camel Case before calling handleChange like:

JavaScript

and camel case converter function will be like:

JavaScript

You can take a look at this sandbox for a live working example.

Advertisement