locked
Setting a field as currency in custom list form (editform) RRS feed

  • Question

  • I have a custom editform that I made in Sharepoint Designer. Most of the fields are currency. However, they do not display as currency, but plain numbers. So far as I can figure out, there is no way to make these fields appear as currency w/in Sharepoint Designer. The best I can do is change the field from a "list form field" to a "text box" and then add a regular expression validator. Is this right? Is there no built-in way to do this simply and quickly?
    Monday, April 18, 2011 4:17 PM

Answers

  • Nerak,

     

    Below is a a currency field from SPD. Unfortunately when you look at the field in SPD there is nothing there to indicate it is Currency to easily write a generic script for you want.

    <SharePoint:FormField runat="server" id="ff14{$Pos}" ControlMode="Edit" FieldName="Amount" __designer:bind="{ddwrt:DataBind('u',concat('ff14',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Amount')}"/>

     

    However, it would fairly easy to write a little bit of jQuery to modify the contents to format the currency when the form is displayed.  

     

    For the field "Amount" above, you could drop the following jQuery on the page in a CEWP to do something as simple as add a "$". You can customize it for whatever your currency standards are:

     

    <script src="<path to your jQuery Library>/jquery.min.js" type="text/javascript"></script>

     

    <script type="text/javascript">

     

    jQuery(document).ready(function($){

    //find a field with the title (fieldName) of "Amount" and add a "$" in front of the contents. 

    $("input[title='Amount']").val("$" + $("input[title='Amount']").val()); 

    })

     

    </script>

     

     

     

    • Marked as answer by Emir Liu Wednesday, April 27, 2011 9:13 AM
    Monday, April 18, 2011 5:22 PM
  • Hi Nerak,

    What's your expectation on "Currency" field? The reason I ask is because you're specifically referring to "Edit Form" and I don't think that you need to customize your form.

    In an Edit form, I expect to have a text field that will only allow digits, not characters. At the same time, I don't expect to enter the "$" in that field. That should show automatically on the "Display Form" or in your view. All of this is actually available out of the box. In your list/library, go to the Settings and set those fields as "Currency". This will also take care of validation in your form.

    You didn't mention anything else about your list. Based on what you've mentioned so far, you don't really need a "Customized" form. Even if you do need it for other purposes, you shouldn't have to do anything with that field control. Just set the field settings appropriately from your browser by going to the settings of that list/library.

    Hope that helps...

     


    Pman
    http://www.pmansLab.com/
    • Marked as answer by Emir Liu Wednesday, April 27, 2011 9:13 AM
    Wednesday, April 20, 2011 1:54 AM

All replies

  • Nerak,

     

    Below is a a currency field from SPD. Unfortunately when you look at the field in SPD there is nothing there to indicate it is Currency to easily write a generic script for you want.

    <SharePoint:FormField runat="server" id="ff14{$Pos}" ControlMode="Edit" FieldName="Amount" __designer:bind="{ddwrt:DataBind('u',concat('ff14',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Amount')}"/>

     

    However, it would fairly easy to write a little bit of jQuery to modify the contents to format the currency when the form is displayed.  

     

    For the field "Amount" above, you could drop the following jQuery on the page in a CEWP to do something as simple as add a "$". You can customize it for whatever your currency standards are:

     

    <script src="<path to your jQuery Library>/jquery.min.js" type="text/javascript"></script>

     

    <script type="text/javascript">

     

    jQuery(document).ready(function($){

    //find a field with the title (fieldName) of "Amount" and add a "$" in front of the contents. 

    $("input[title='Amount']").val("$" + $("input[title='Amount']").val()); 

    })

     

    </script>

     

     

     

    • Marked as answer by Emir Liu Wednesday, April 27, 2011 9:13 AM
    Monday, April 18, 2011 5:22 PM
  • Hi Nerak,

    What's your expectation on "Currency" field? The reason I ask is because you're specifically referring to "Edit Form" and I don't think that you need to customize your form.

    In an Edit form, I expect to have a text field that will only allow digits, not characters. At the same time, I don't expect to enter the "$" in that field. That should show automatically on the "Display Form" or in your view. All of this is actually available out of the box. In your list/library, go to the Settings and set those fields as "Currency". This will also take care of validation in your form.

    You didn't mention anything else about your list. Based on what you've mentioned so far, you don't really need a "Customized" form. Even if you do need it for other purposes, you shouldn't have to do anything with that field control. Just set the field settings appropriately from your browser by going to the settings of that list/library.

    Hope that helps...

     


    Pman
    http://www.pmansLab.com/
    • Marked as answer by Emir Liu Wednesday, April 27, 2011 9:13 AM
    Wednesday, April 20, 2011 1:54 AM