Posts

Showing posts from August, 2017

Validate Input Phone Number in Microsoft Dynamics CRM using JavaScript

Sometime we get requirement to validate a phone number like to check only numeric value allowed with all round bracket and '+' sign etc in the number. So below is a basic JavaScript fucntion which validates a phone number like: (022)6655-7878 or +91-7878787878 or +44-6756-6767-4234 and so on function CheckPhoneNoFormat(context) {     var oField = context.getEventSource().getValue();     if (typeof (oField) != "undefined" && oField != null) {         try {             var telnum = oField;             // Convert into a string and check that we were provided with something             var telnum = telnum + " ";             if (telnum.length == 1) {                 telNumberErrorNo = 1;                 return false             }             telnum.length = telnum.length - 1;             // Remove spaces from the telephone number to help validation             while (telnum.indexOf(" ") != -1) {                 telnum = telnum
go to top image