Only assign RegExp if property is different from false

This commit is contained in:
Benoit Rapidel 2020-11-09 18:49:49 +01:00
parent 04f75fc30d
commit 0bb7a2bdf6

View file

@ -58,7 +58,9 @@ class Input extends Canvas {
this.tabKeyBlur = false
})
var asYouType = this.getProp('asYouType')
this.fieldValidator = new RegExp('[^'+this.getProp('fieldValidator')+']', 'g')
if (this.getProp('fieldValidator')) {
this.fieldValidator = new RegExp('[^'+this.getProp('fieldValidator')+']', 'g')
}
this.input.addEventListener('keydown', (e)=>{
if (e.keyCode === 13) this.blur() // enter
else if (e.keyCode === 27) this.blur(false) // esc