You can not ackomplish this with CSS. You could easily do this in a server-side environment like JSP or ASP. You would simply create a variable and set that variable's value = to the javascript command you want to execute. You could then place that variable inside each of the form elements that require this script. Otherwise, if you are in a static environment, ie HTML, you are left with placing the javascript function in each form element.