locked
URL Encoding when a form loads RRS feed

  • Question

  • Hi all, when the account form loads, I have some OnLoad code that I'm using (below) that drags the "accountid" into an empty, read only field. I want to be able to clean the "accountid" data so as to format it to be suitable to be passed as in a URL parameter (this entails removing the curly brackets, any punctuation characters, dashes etc). Any ideas how I can add that code to the following snippet? Thanks.

    if (crmForm.FormType != 1) {
    crmForm.all.accountnumber.DataValue = crmForm.ObjectId;
    }

     

    Sunday, February 20, 2011 3:35 PM

Answers

  • Regular expressions:

    crmForm.all.<fieldname>.DataValue = crmForm.ObjectId.replace(/[^0-9A-Za-z]+/g, "");
    
    

    --pogo (pat)
    • Proposed as answer by Cornel Croitoriu Monday, February 21, 2011 11:48 AM
    • Marked as answer by Ascomptrs Monday, February 21, 2011 2:05 PM
    Sunday, February 20, 2011 11:10 PM

All replies

  • Regular expressions:

    crmForm.all.<fieldname>.DataValue = crmForm.ObjectId.replace(/[^0-9A-Za-z]+/g, "");
    
    

    --pogo (pat)
    • Proposed as answer by Cornel Croitoriu Monday, February 21, 2011 11:48 AM
    • Marked as answer by Ascomptrs Monday, February 21, 2011 2:05 PM
    Sunday, February 20, 2011 11:10 PM
  • Rockstar, thats fantastic. Long time since I used regex on unix in college!

     

    Monday, February 21, 2011 2:05 PM