javascript - Make a textarea all caps? -


i trying make textarea type in caps, if user isn't holding down shift or has caps lock on. ideally accept input no matter , automatically shift caps. of ways thinking of seem kind of clunky , show lowercase before gets converted.

any suggestions or strategies?

you can use css

textarea { text-transform: uppercase; } 

however, renders on browser. let's if want inject text script or db in textarea caps you'll have use javascript's touppercase(); before injection or form submit.

here jsfiddle example:

html:

<textarea>i javascript</textarea> 

css:

textarea{  text-transform: uppercase; } 

javascript:

var mytextarea = document.getelementsbytagname('textarea');  for(var i=0; i<mytextarea.length; i++){     console.log('textarea ' + + ' output: ' + mytextarea[i].innerhtml);  //i javascript     console.log('textarea ' + + ' converted output: ' + mytextarea[i].innerhtml.touppercase()); //i javascript } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -