thespot4sap.com independent sap information
 

get SAP Access - pay monthly

SAP Tutorials    Online SAP Training    SAP CBT's    SAP Forums    SAP Articles    SAP Jobs    SAP Resumes
  SAP Access    SAP Blogs    SAP Books     Links     SAP Vendor Directory     Submit Content    Search
Previous posts in SAP CRM
Page 5401 of 5660

Input Masking on CRM Forms

Blogger : MSDN Blogs
All posts : All posts by MSDN Blogs
Category : SAP CRM
Blogged date : 2006 Jan 12

Here is an example on how you can customize MS CRM forms taking advantage of the On Change event.  Thanks Danny Knight for this Sample Codes.

How it works?  We would like the phone numbers to be auto-formatted with Parentheses and dashes.  Using this sample code, you can just type the number as per usual and the code will automatically mask it with the desired formatting.

In order to do this, you have to be in the Forms Customization section of MS CRM under Settings.  You just double click the Telephone Field and select on the Event Tab and you should be able to see On change event. Just paste this code and save the form.

// Attempt to auto-format basic phone numbers.  This method supports
// 7 and 10 digit numbers.  Example: (410) 555-1212
 
// Get the field that fired the event
var oField = event.srcElement;
 
// If we have the field and all is well
if (typeof(oField) != "undefined" && oField != null)
{
 // Remove any non-numeric characters
 var sTmp = oField.DataValue.replace(/[^0-9]/g, "");
 
 // If the number is a length we expect and support, format the number
 switch (sTmp.length)
 {
  case "4105551212".length:
   oField.DataValue = "(" + sTmp.substr(0, 3) + ") " + sTmp.substr(3, 3) + "-" + sTmp.substr(6, 4);
   break;
 
  case "5551212".length:
   oField.DataValue = sTmp.substr(0, 3) + "-" + sTmp.substr(3, 4);
   break;
 }
}


Read comments or post a reply to : Input Masking on CRM Forms
Page 5401 of 5660

Newest posts
New Page 1

 

 

About Us   Contact Us   Privacy   Disclaimer   Feedback   Email Discussion   Newsletter  

Copyright © - Independent SAP Information
Learn XML, Guesthouses and B&B's