I'm trying to do a textTransform on a standard Sharepoint text field. The problem is that all the examples I can find do it via a "onblur". When I add this I get an error on the page, my presumption is that it can't handle that element.

<SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="New" FieldName="Product_x0020_Description" __designer:bind="{ddwrt:DataBind('i',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Product_x0020_Description')}" onblur="upperCase()"/>

function upperCase() {getField('input', 'Product Description').style.textTransform."uppercase"}

Is there any way I can do this without having to add a standard input field?

Thanks in Advance.


You do not need JavaScript for this, you could use plain CSS like this:

input { text-transform: uppercase }

You could use the property CssClass to set a class and select by that.

I'm not sure what you are trying to do though, because this will let the user think the values inserted are upper case, but at an actual post it will be in whatever case they used when inputting.
If you wan't to force the input to be upper case client side (note that this can easily be bypassed) you can do something like this (example with jQuery):

$('form').submit(function() {
   // Guessing this is the title based on your code
   var $field = $('[title=Product Description]');
  • Hi Eirikb,Yeah I tried the CSS version first but the text field kept ignoring my cssClass and applying its own. I obviously have to dig further into the style ordering. No worries though as I tried the jQuery way and that work a treat. Thanks for you help. – sansSpoon Oct 15 '12 at 5:34
  • Using a good dev tool (such as WebKit dev tools in Chrome) and inspecting can get you far (in seeing why your style properties are not applied). Using !important although this is a bit hackish – eirikb Oct 15 '12 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.