I'm currently doing a project for my class and I really need help on this one. I have a text input in wich the user will have to enter his permanent code (1234567, 7654321...) But I would like to return the first character so that the user would only be able to enter numbers that are starting with either 1 or 2. if(1234567) = good / if(7654321) = error! My problem is that the charAt(0) thingy doesn't seem to work with inputs for me.
const code = document.getElementById('user_code');
const checkup = code.charAt(0);
button.addEventListener('click', ()=>{
console.log(checkup);
})
Thank you for your help! I am not used to talk nor write in english so sorry for the mistakes!
I tried those things : document.getElementById('user_code').innerHTML; and document.getElementById('user_code').innerText; and console.log(checkup.ToString);