how to use one javascript function for multiple input fields

In HTML, form types such as