How reference a component with JavaScript

Hi i have a question , i know that i can put pure code Javascript with Vaadin Like JavaScript.eval(

“…”); but if i want to reference a textfield with javascript ? i mean make a event like onkeypress and put that event in the textfield when the screen appear.
A good example is make a validator of only letters and numbers , but only with Javascript not going to backend , is that possible ?

Thanks !

You don’t want to reference any componets through a JS.eval. In order to do that kind of stuff I would recommend creating an extension, https://vaadin.com/wiki?p_p_id=36&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=row-1&p_p_col_pos=2&p_p_col_count=4&_36_struts_action=%2Fwiki%2Fview&p_r_p_185834411_nodeName=vaadin.com+wiki&p_r_p_185834411_title=Creating+a+component+extension

You can also look at the one client side validator addon in the directory if that might satisfy your needs https://vaadin.com/directory#addon/csvalidation:vaadin