{"id":65293,"date":"2007-03-17T01:45:00","date_gmt":"2007-03-17T01:45:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2007\/03\/17\/how-can-i-force-a-specified-letter-case-in-an-hta\/"},"modified":"2007-03-17T01:45:00","modified_gmt":"2007-03-17T01:45:00","slug":"how-can-i-force-a-specified-letter-case-in-an-hta","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/how-can-i-force-a-specified-letter-case-in-an-hta\/","title":{"rendered":"How Can I Force a Specified Letter Case in an HTA?"},"content":{"rendered":"<p><H2><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Question\" height=\"34\" alt=\"Hey, Scripting Guy! Question\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"> <\/H2>\n<P>Hey, Scripting Guy! In our company we often use HTAs as data entry forms. For some of our applications case-sensitivity is important; for example, our product numbers are case-sensitive. I know I can write a script to change letter case, but I was wondering if there was a way to force letter case (either all uppercase or all lowercase) at the time people actually do their data entry.<BR><BR>&#8212; SK<\/P><IMG height=\"5\" alt=\"Spacer\" src=\"https:\/\/devblogs.microsoft.com\/scripting\/wp-content\/uploads\/sites\/29\/2019\/05\/spacer.gif\" width=\"5\" border=\"0\"><IMG class=\"nearGraphic\" title=\"Hey, Scripting Guy! Answer\" height=\"34\" alt=\"Hey, Scripting Guy! Answer\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" width=\"34\" align=\"left\" border=\"0\"><A href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=68779&amp;clcid=0x409\"><IMG class=\"farGraphic\" title=\"Script Center\" height=\"288\" alt=\"Script Center\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/ad.jpg\" width=\"120\" align=\"right\" border=\"0\"><\/A> \n<P>Hey, SK. You know, the great thing about this column \u2013 oh, wait; that\u2019s a different column. In fact, now that we think about it, we can\u2019t come up with any great things about <I>this<\/I> column. Be that as it may, however, the <I>interesting<\/I> thing about this column is that \u2013 well, you\u2019re right: that really isn\u2019t all that interesting, is it? Hmmm \u2026.<\/P>\n<P>OK, let\u2019s try this again. You know, the not-so-great and not-all-that-interesting thing about this column (better?) is that we Scripting Guys probably learn more from writing the column than anyone does from reading it. Based on the emails we receive we know that some of you (obviously those who don\u2019t know us very well) assume that the Scripting Guys can answer any scripting question at all, and right off the top of our heads. And you know, come to think of it, maybe we <I>can<\/I> answer any question that people ask:<\/P>\n<P>\u201cHey, Scripting Guy! How can I force letter case when people do data entry?\u201d<\/P>\n<P>\u201cBeats us.\u201d<\/P>\n<P>Technically, \u201cBeats us\u201d <I>is<\/I> an answer. It\u2019s just not a very <I>good<\/I> answer.<\/P>\n<P>But don\u2019t fret, SK. Following our usual pattern, we did a bit of research and managed to come up with a better answer for you:<\/P><PRE class=\"codeSample\">&lt;body&gt;\n    Box 1 &lt;input type=&#8221;text&#8221; name=&#8221;Box1&#8243; size=&#8221;30&#8243; style=&#8221;text-Transform:uppercase&#8221;&gt;&lt;P&gt;\n&lt;\/body&gt;\n<\/PRE>\n<P>As you can see, this is perhaps the simplest HTA ever created: there\u2019s nothing to it except for a single text box. But take a look at the HTML tag for that text box:<\/P><PRE class=\"codeSample\">&lt;input type=&#8221;text&#8221; name=&#8221;Box1&#8243; size=&#8221;30&#8243; style=&#8221;text-Transform:uppercase&#8221;&gt;\n<\/PRE>\n<P>What we\u2019ve done here is apply a style to the box; in particular, we\u2019ve assigned a value to the <B>text-Transform<\/B> attribute: <B>style=&#8221;text-Transform:uppercase&#8221;<\/B>. Is there a method behind that madness? You bet there is: setting text-Transform to <I>uppercase<\/I> automatically converts any text typed into that box to its uppercase equivalent. Best of all, you can do that without having to write any script code.<\/P>\n<P>And, now that you mention it, yes, there <I>are<\/I> other values you can assign to text-Transform. For one, you can assign the value <I>lowercase<\/I> to convert all the letters typed into the box to their lowercase equivalent. For another, you can assign the value <I>capitalize<\/I> to make the first letter in each word uppercase (subsequent letters in the word are not converted; they show up exactly as you type them). Here\u2019s a sample HTA that uses each of these text-Transform values. Take a close look at the letter casing in each text box; all the letters in all three boxes were typed using lowercase. But, as you can see, they don\u2019t all show up as lowercase:<\/P><IMG height=\"251\" alt=\"HTA\" src=\"http:\/\/img.microsoft.com\/library\/media\/1033\/technet\/images\/scriptcenter\/qanda\/transform.jpg\" width=\"350\" border=\"0\"> \n<P><BR>And here\u2019s the HTML tagging we used to create this sample form:<\/P><PRE class=\"codeSample\">&lt;body&gt;\n    Box 1 &lt;input type=&#8221;text&#8221; name=&#8221;Box1&#8243; size=&#8221;30&#8243; style=&#8221;text-transform:uppercase&#8221;&gt;&lt;P&gt;\n    Box 2 &lt;input type=&#8221;text&#8221; name=&#8221;Box2&#8243; size=&#8221;30&#8243; style=&#8221;text-transform:lowercase&#8221;&gt;&lt;P&gt;\n    Box 3 &lt;input type=&#8221;text&#8221; name=&#8221;Box3&#8243; size=&#8221;30&#8243; style=&#8221;text-transform:capitalize&#8221;&gt;&lt;P&gt;\n&lt;\/body&gt;\n<\/PRE>\n<P>Pretty cool, huh?<\/P>\n<P>We might add that although SK didn\u2019t want to use a script to modify letter case <I>you<\/I> (or even you, the guy in the green) can use a script if you so choose. Here\u2019s a modified HTA that features a button that toggles between lowercase and uppercase:<\/P><PRE class=\"codeSample\">&lt;Script Language=&#8221;VBScript&#8221;&gt;\n    Sub CaseChanger\n        If Box1.Style.textTransform=&#8221;lowercase&#8221; Then\n            Box1.Style.textTransform=&#8221;uppercase&#8221;\n        Else\n            Box1.Style.textTransform=&#8221;lowercase&#8221;\n        End If\n    End Sub\n&lt;\/Script&gt;<\/p>\n<p>&lt;body&gt;\n    Box 1 &lt;input type=&#8221;text&#8221; name=&#8221;Box1&#8243; size=&#8221;30&#8243;&gt;&lt;P&gt;\n    &lt;input  type=&#8221;button&#8221; Value=&#8221;Run&#8221; type=&#8221;button&#8221; onClick=&#8221;CaseChanger&#8221; style=&#8221;text-Transform:lowercase&#8221;&gt;\n&lt;\/body&gt;\n<\/PRE>\n<P>The cool thing here is that it not only toggles the style assigned to the text box, but it dynamically changes the letter case for any text currently <I>in<\/I> the text box.<\/P>\n<P>We hope that helps, SK. And we hope that you learned something today, because \u2013 as usual \u2013 the Scripting Guys learned something: we learned that it would be much better if we did our research ahead of time so that we <I>could<\/I> answer questions off the top of our heads. And so, by golly, we\u2019re going to do that: we\u2019re going to do our homework and learn everything there is to know about scripting. <\/P>\n<P>But not today; today the Scripting Son has a baseball game and we need to leave early. But tomorrow, tomorrow we start.<\/P>\n<P>Well, actually, the NCAA men\u2019s basketball tournament is tomorrow. But next week, next week for sure.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey, Scripting Guy! In our company we often use HTAs as data entry forms. For some of our applications case-sensitivity is important; for example, our product numbers are case-sensitive. I know I can write a script to change letter case, but I was wondering if there was a way to force letter case (either all [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3,4,5,30],"class_list":["post-65293","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-scripting-guy","tag-scripting-techniques","tag-vbscript","tag-web-pages-and-htas"],"acf":[],"blog_post_summary":"<p>Hey, Scripting Guy! In our company we often use HTAs as data entry forms. For some of our applications case-sensitivity is important; for example, our product numbers are case-sensitive. I know I can write a script to change letter case, but I was wondering if there was a way to force letter case (either all [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/65293","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=65293"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/65293\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=65293"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=65293"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=65293"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}