28 October 2009

Case static fields

At the beginning let’s do something easy but quite useful if you want to force user to use upper or lower case letters in text field.
We can achieve it in two ways – by using javascript or CSS. I prefer second method because it's more “pure” in my opinion.
Create text item (P1_TEXT) in your page. Go to item details and find HTML Form Element Attributes. Write there new style or add following attribute to existing one:

style="text-transform: uppercase;"


Of course instead of “uppercase”, you can use “lowercase” option. Accept changes and the only letters you can enter in P1_TEXT are upper.
If you want to use javascript you should add to the same HTML Form Element Attributes field, following JS code:

onKeyUp=”$x(‘P1_TEXT’).value=$x(‘P1_TEXT’).value.toUpperCase();”
or
onKeyUp=”this.value=this.value.toUpperCase();” 

Apply changes and now every time you click some key on P1_TEXT, its value will be changed dynamically to upper case.

1 comment:

Pawel Co Faddey said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from JQuery Training in Chennai . or learn thru JQuery Training . or learn thru ES6 Online Training. Nowadays JavaScript has tons of job opportunities on various vertical industry.