Search This Blog

Monday, 10 August 2020

Bootstrap zipcode validation for country US and Canada

----------------------------------------------------------------------------------------------

$('#formID').bootstrapValidator({

       feedbackIcons: {

           valid: 'glyphicon glyphicon-ok',

           invalid: 'glyphicon glyphicon-remove',

           validating: 'glyphicon glyphicon-refresh'

       },

       fields: {

           InputZip: {

               validators: {

               callback: {

                        message: 'The zip is not valid postal code',

                        callback: function (value, validator, $field) {

                        var country = $("#InputCountry").val();                      

                        switch (country) {

                            case 'CA':

                                return /^(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|X|Y){1}[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}\s?[0-9]{1}(?:A|B|C|E|G|H|J|K|L|M|N|P|R|S|T|V|W|X|Y|Z){1}[0-9]{1}$/i.test(value);

                            case 'US':

                            default:

                                return /^\d{4,5}([\-]\d{4})?$/.test(value);

                        }

                        }

                    }

               }

           }

          

       }

   });

----------------------------------------------------------------------------------------------

Sunday, 9 August 2020

Kendo Grid - Add tooltip to Kendo Grid Header

       

 ----------------------------------------------------------------------

     var gridName = "myKendoGridID";

      $("#"+gridName+" thead tr th").each(function(e){
$(this).attr('title', $(this).text());
      });

----------------------------------------------------------------------