JavaScript: Convert characters to uppercase when typing

Filed in: Web Development — April 7th, 2004

advertisement

In some web form fields, we required user to fill in data in uppercase. We can do this by appyling a javascript function.

Code:
<script>
function uppercase()
{
key = window.event.keyCode;
if ((key > 0x60) && (key < 0x7B))
window.event.keyCode = key-0x20;
}
</script>

Then, add onKeypress="uppercase();" in the field that you want to have uppercase strings. Done!

Source: Making HTML as Functional as a Green Screen

Read also:

  • Very interesting, lcf... :D BTW, can link to my blog-ah? *wink* *wink*

    - MENJ
blog comments powered by Disqus