'Material UI TextField Regex

I need two textbox from TextField from MaterialUI one that can only enter alphabets(small or capital can also include spaces {Example : Risha Raj} as first textfield) and other one is also except only alphabets (small or capital) but with maxLength with only 3

so I did the following

           <TextField
            id='Product Name'
            label='Enter Student  Name'
            name='sname'
            value={values.sname}
            onChange={handleChange}
            error={errors.sname}
          />
            <TextField
            id='section'
            label='Enter Class Section'
            name='ccode'
            inputProps={{maxLength:3}}
            value={values.ccode}
            onChange={handleChange}
            error={errors.ccode}
          />

I am able to restrict the length but unable to do the alphabets



Solution 1:[1]

This has nothing to do with Material UI.

You need to create a validator function on your handleChange.

See: How to set input alphanumeric value format in input field reactjs?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Almaju