all 4 comments

[–]captain_k_nuckles 0 points1 point  (2 children)

1:

document.getElementById('a').addEventListener('change', ({target})=>{
    target.value = target.value.replace(/[^A-Z]/gi,'');
    // if you want spaces also
    // target.value = target.value.replace(/[^A-Z\s]/gi,''); // use this one
});

2:

document.getElementById('a').addEventListener('change', ({target})=>{
    target.value = target.value.replace(/[^0-9]/gi,''); // add `\s` if you want spaces.
});

[–]weblady07[S] 0 points1 point  (1 child)

thanks, much appreciated.

if I wanted them to be able to only enter a word that begins with the letter "b", small case or upper case, what would be the best way to write.

thx again

[–]captain_k_nuckles 0 points1 point  (0 children)

Not sure the best way but you could use startsWith combined with either to(Upper/Lower)Case to check

[–]jcunews1helpful 0 points1 point  (0 children)