locked
validation on phone numbers RRS feed

  • Question

  • hi frnds,

    i m working on ms crm 4.0..

    i want to put javascript  which can use for international mobile number validation in the form of entity lead..

    so guys please give me the javascript code for it if you know that..

    also provide code for international landline numbers..

    Regards,

    Amit


    Tuesday, January 3, 2012 10:38 AM

Answers

  • Hi, Amit

    try this.

    /\(?\d{3}\)?[-\/\.\s]?\d{3}[-\/\.\s]?/
    regards kartik

    Tuesday, January 10, 2012 1:02 PM

All replies

  • Hi Amit,

    // Get the field that fired the event.
    var oField = event.srcElement;
    
    // Validate the field information.
    if (typeof(oField) != "undefined" && oField != null)
    {
     // Remove any non-numeric characters.
     var sTmp = oField.DataValue.replace(/[^0-9]/g, "");
    
     // If the number has a valid length, 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;
     }
    }
    
    

    Regards,


    Philippe

    Blog : Dynamics CRM pour les francophones/for French speakers

    Please remember to click "Vote as Helpful" and “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    • Proposed as answer by Philippe LEAL Tuesday, January 3, 2012 12:44 PM
    • Unproposed as answer by Philippe LEAL Friday, June 8, 2012 1:31 PM
    Tuesday, January 3, 2012 11:16 AM
  • Hi Amit,

     Please go thru this fine article

    http://joegilldotcom.blogspot.com/2011/03/crm-2011-phone-format-validation-using.html

     HTH

    dkay

     

     if the response answered your question, please take a minute and mark the response as an answer.

     

     

    • Proposed as answer by D kay Tuesday, January 3, 2012 11:24 AM
    Tuesday, January 3, 2012 11:24 AM
  • hi frnds,

    i just want the regular expression which can be write in the Onchange event of the Businessphone field of lead.

    i dont need the code you have written above Philippe.

    but thanks for your suggestions.

    Regards,

    Amit Kasundra

    Wednesday, January 4, 2012 5:50 AM
  • Hi, Amit

    try this.

    /\(?\d{3}\)?[-\/\.\s]?\d{3}[-\/\.\s]?/
    regards kartik

    Tuesday, January 10, 2012 1:02 PM