cleave.js icon indicating copy to clipboard operation
cleave.js copied to clipboard

Cannot read property 'inputType' of undefined

Open alextbogdanov opened this issue 4 years ago • 4 comments

I get this error: Uncaught TypeError: Cannot read property 'inputType' of undefined at i.onChange (cleave.min.js:8) at i.setPhoneRegionCode (cleave.min.js:8)

anytime I try to use any function of the cleave instance!!!

alextbogdanov avatar Jun 17 '20 00:06 alextbogdanov

I'm also seeing this issue --

Uncaught TypeError: Cannot read property 'inputType' of undefined at i.onChange (cleave.min.js:formatted:126) at i.setPhoneRegionCode (cleave.min.js:formatted:225) at HTMLSelectElement.

The problem is that onChange: function(e) {} uses e.inputType but when changing the phone region code, it calls onChange() without passing an event.

graham-saunders avatar Jul 30 '20 19:07 graham-saunders

Same issue

jonahsantos avatar Oct 01 '20 18:10 jonahsantos

This is working in my case: Just changing the prop without using setPhoneRegionCode

select.addEventListener('change', function(){ cleave.phoneRegionCode = this.value; cleave.setRawValue(''); })

Hope it helps!

MrEscape54 avatar Dec 23 '20 17:12 MrEscape54

In the cleave.min.js file in v1.6.0, locate and change this code:

t.isBackward=t.isBackward||"deleteContentBackward"===e.inputType;

To:

t.isBackward=t.isBackward||(typeof e!=="undefined"&&"deleteContentBackward"===e.inputType);

In my case, "e" is actually undefined. By introducing the typeof check, the "setPhoneRegionCode" method works as expected.

davidenco avatar Jan 14 '22 15:01 davidenco