fix for this error: Uncaught TypeError: Cannot call method 'valid' of un...

...defined