Beispiel #1
0
 /// <summary>
 /// Validates Postal Code
 /// Reformats Postal Code
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public static string JBCanadianPostalCodeFormat(string input)
 {
     if (JBValidations.JBCanadianPostalCodeValidation(input))
     {
         input = input.Replace(" ", "").Replace("-", "");
         input = input.Insert(3, " ");
         return(input.ToUpper());
     }
     else
     {
         throw new Exception("Postal code could not be reformatted\nbecause it is not a valid postal code.");
     }
 }
Beispiel #2
0
 /// <summary>
 /// Validates Phone Number
 /// Reformats Phone Number
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public static string JBPhoneNumberFormat(string input)
 {
     if (JBValidations.JBPhoneNumberValidation(input))
     {
         input = input.Replace(" ", "").Replace("-", "").Replace("(", "").Replace(")", "");
         input = input.Insert(3, "-").Insert(7, "-");
         return(input.ToUpper());
     }
     else
     {
         throw new Exception("Phone number could not be reformatted\nbecause it is not a valid phone number.");
     }
 }
Beispiel #3
0
 /// <summary>
 /// Validates US Zip Code
 /// Reformats US Zip Code
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public static string JBUnitedStatesZipCodeFormat(string input)
 {
     if (JBValidations.JBUnitedStatesZipCodeValidation(input))
     {
         if (input.Length > 5)
         {
             input = input.Replace(" ", "").Replace("-", "");
             input = input.Insert(5, "-");
         }
         return(input.ToUpper());
     }
     else
     {
         throw new Exception("Zip code could not be reformatted\nbecause it is not a valid zip code.");
     }
 }