I need a specific input field on the page to have its text changed to uppercase. I am aware that CSS can be used to display uppercase on the page but I need this javascript as the underlying input data has to be uppercase.
I am using javascript below to change the text to uppercase on input fields on my website
function handleInput(e) {
document.getElementsByClassName("bottomtext");
var ss = e.target.selectionStart;
var se = e.target.selectionEnd;
e.target.value = e.target.value.toUpperCase();
e.target.selectionStart = ss;
e.target.selectionEnd = se;
}
this is being called via php using:
'oninput' => 'handleInput(event)',
my only problem is that it is being applied to all input fields on the page, but I only want it applied to a specic field with the class "bottomtext". Can someone please help with having this only apply to the specific class. Thank you.