locked
Microsoft Dynamics CRM 2011 - onChange event UpperCase text RRS feed

  • Question

  • Hello,

    Does anyone know any javascript which will assist me with changing all text in a text field from lower case to upper case on change, for example the postcode/zipcode field?

    Regards


    Sam

    Thursday, September 19, 2013 11:31 AM

Answers

  • You can use this javascript function:

    function UpperCaseField(fieldName) {
       var value = Xrm.Page.getAttribute(fieldName).getValue();
       if (value != null) {
          Xrm.Page.getAttribute(fieldName).setValue(value.toUpperCase());
       }
    }

    and after use as:

    UpperCaseField("address1_postalcode");


    My blog: www.crmanswers.net


    • Edited by Guido PreiteMVP Thursday, September 19, 2013 12:01 PM
    • Marked as answer by samrr1875 Thursday, September 19, 2013 1:16 PM
    Thursday, September 19, 2013 12:00 PM

All replies

  • If it is a text field, try this:

    var temp = Xrm.Page.getAttribute("<attributeName">).getValue();
    Xrm.Page.getAttribute("<attributeName">).setValue(temp.toUpperCase());


    Zarko


    • Edited by Radevic Thursday, September 19, 2013 12:01 PM edit
    Thursday, September 19, 2013 11:48 AM
  • You can use this javascript function:

    function UpperCaseField(fieldName) {
       var value = Xrm.Page.getAttribute(fieldName).getValue();
       if (value != null) {
          Xrm.Page.getAttribute(fieldName).setValue(value.toUpperCase());
       }
    }

    and after use as:

    UpperCaseField("address1_postalcode");


    My blog: www.crmanswers.net


    • Edited by Guido PreiteMVP Thursday, September 19, 2013 12:01 PM
    • Marked as answer by samrr1875 Thursday, September 19, 2013 1:16 PM
    Thursday, September 19, 2013 12:00 PM
  • You don't need to pass execution context as the first parameter, just the field name. How do you call this function in code? You should call it UpperCaseField('address1_postalcode');

    Zarko

    Thursday, September 19, 2013 12:17 PM
  • Thank you, much appreciated.
    Thursday, September 19, 2013 1:26 PM