Tuesday, 24 August 2021

Decimal Numeric validation on textbox using jquery with all possible condition onkeydown

  /////////////////////////////// HTML

<input type="text" name="decimal" id="decimal" onkeydown="return Validate_NumerDecimal(this,event,8)">

//////////////////////////// JQUERY


<script>

        function Validate_NumerDecimal(th, event, mxlen, decNum) {
            decNum = (decNum == undefined || decNum == "" || decNum == null) ? 0 : decNum;
            var keyArr = [0, 8, 36, 37, 38, 39, 46, 190];
            var codes = event.keyCode || event.which;
            if ($(th).val()=="" && codes == 190) {
                return false
            }
            else if ((keyArr.indexOf(codes) == -1) && (codes < 48 || codes > 57)) {             
                return false;
            }
            else if ((keyArr.indexOf(codes) > 0)) {
                if ($(th).val().indexOf('.') > 0 && codes == 190) {
                    return false
                }
                setTimeout(function () {
                    if ($(th).val().indexOf('.') == -1 && $(th).val().length > mxlen) {
                        let str = $(th).val();
                        $(th).val(str.substr(0, mxlen));
                    }
                }, 10);
                return true;
            }
            else {
                var dotPos = $(th).val().indexOf('.');
                if (dotPos < 0) {
                    if ($(th).val().length < mxlen || codes == 46) {
                        return true;
                    }
                    else {
                        return false;
                    }
                }
                else {
                    if ($(th).val().length >= dotPos && $(th).val().length < dotPos + (decNum + 1) && codes != 46) {
                        var number = th.value.split('.');
                        var caratPos = getSelectionStart(th);
                        if (caratPos <= dotPos) {
                            if (number[0].length < mxlen) {
                                return true;
                            }
                            else {
                                return false;
                            }
                        }
                        else if (caratPos > dotPos && dotPos > -1 && (number[1].length > (decNum))) {
                            return false;
                        }
                        else {
                            return true;
                        }
                    }
                    else {
                        return false;
                    }
                }
            }
 
            function getSelectionStart(th) {
                if (th.createTextRange) {
                    var r = document.selection.createRange().duplicate()
                    r.moveEnd('character', th.value.length)
                    if (r.text == ''return th.value.length
                    return th.value.lastIndexOf(r.text)
                } else return th.selectionStart
            }
        }
    </script>

Decimal Numeric validation on textbox using jquery with all possible condition onkeypress

 /////////////////////////////// HTML

<input type="text" name="decimal" id="decimal" onkeypress="return Validate_NumerDecimal(this,event,8)">

//////////////////////////// JQUERY


<script>     

/////////////////////////// onkeypress
        function Validate_NumerDecimalPress(th, event, mxlen, decNum) {
            if ((event.which != 46) &&
                ((event.which < 48 || event.which > 57) &&
                    (event.which != 0 && event.which != 8))) {
                event.preventDefault();
                return false;
            }
            debugger;
            var dotPos = $(th).val().indexOf('.');
            if (dotPos < 0) {
                if ($(th).val().length < mxlen || event.keyCode == 46) {
                    return true;
                }
                else {
                    event.preventDefault();
                    return false;
                }
            }
            else {
                if ($(th).val().length >= dotPos && $(th).val().length < dotPos + 3 && event.keyCode != 46) {
                    debugger;
                    var number = th.value.split('.');
                    var caratPos = getSelectionStart(th);
                    if (caratPos <= dotPos) {
                        if (number[0].length < mxlen) {
                            return true;
                        }
                        else { event.preventDefault(); return false; }
                    }
                    else if (caratPos > dotPos && dotPos > -1 && (number[1].length > decNum)) {
                        event.preventDefault(); return false;
                    }
                    else {
                        return true;
                    }
                }
                else {
                    event.preventDefault();
                    return false;
                }
            } 
        } 
    </script>

Tuesday, 3 August 2021

Postgres: Query to search any text in all procedures

 ////////// Query


select * from (
select pg_get_functiondef(oid) as def
from pg_proc
where proname like 'fn_%') a where upper(def) ilike '%ENTITY_REGION_PROVINCE_MAPPING%' ;

Monday, 19 July 2021

How to Convert Color html hex color to KML color format using c#

 

List<string> result = new List<string>(System.Text.RegularExpressions.Regex.Split(HTMLHEXCOLORCODE.Replace("#",""), @"(?<=\G.{2})", System.Text.RegularExpressions.RegexOptions.Singleline));

               string clrsKML="FF" + result[2] + result[1] + result[0];

Thursday, 10 June 2021

Chosen multiselect gets "cut" when placed in area with overflow flow or hidden

 //////////// JS
<script type="text/javascript">
    $(document).ready(function () {
  $('.select-chosen').chosen({
        width: "150px"
    });
        FixChosenOverHidden($('.select-chosen'));
    });
 
    function FixChosenOverHidden($chosenSelect) {
        // Disable mouse scroll if its dropdown is open.
        $chosenSelect
            .bind('chosen:showing_dropdown', function () {
                $(this).next('.chosen-container')
                    .bind("mousewheel", function () {
                        return false;
                    });
            })
            .bind('chosen:hiding_dropdown', function () {
                $(this).next('.chosen-container')
                    .unbind('mousewheel');
            });
 
        // Reposition the dropdown to fixed, so it's always on top.
        $('.chosen-container')
            .bind('mouseenter.chosen', function () {
                var x = $(this).offset().left,
                    y = $(this).offset().top + $(this).height(),
                    w = $(this).width(),
                    $dropdown = $(this).find('.chosen-drop');
 
                // If the menu is partially visible, don't change
                // its dropdown to be fixed. This is only needed if your
                // chosen menu might be clipped by a div or something.
 
                // Find all the parents that might be clipping off.
                var parents = $(this).parents().filter(function () {
                    var overflow = $(this).css('overflow');
                    return overflow === 'auto' || overflow === 'hidden' || overflow === 'scroll';
                });
 
                // If at least one parent is clipping off the bottom of
                // the menu, don't proceed any further.
                for (var i = 0; i < parents.length; i++) {
                    var parentEdge = $(parents[i]).offset().top + $(parents[i]).outerHeight();
                    if (y > parentEdge) {
                        $dropdown.css({ 'display': 'none' });
                        return false;
                    }
                }
 
                $dropdown.addClass('fixed')
                    .css({ 'top': y, 'left': x, 'width': w });
            })
            .bind('mouseleave.chosen', function () {
                $(this).find('.chosen-drop')
                    .removeClass('fixed')
                    .attr('style', '');
            });
    }
</script>
///////////////////// HTML
<select class="select-chosen">
        <option>1 A</option>
        <option>2 B</option>
        <option>3 C</option>
        <option>4 A</option>
        <option>5 B</option>
        <option>6 C</option>
        <option>7 A</option>
        <option>8 B</option>
        <option>9 C</option>
        <option>10 A</option>
        <option>1 B</option>
        <option>2 C</option>
        <option>3 A</option>
        <option>4 B</option>
        <option>5 C</option>
    </select>



Sunday, 23 May 2021

jQuery load() method for calling partial view in mvc with loading progress bar

 //////////// HTML


  <div class="EEReport Summary" id="divSummary">
        <div id="Progressbar" class="ExportReportProgress"></div>
        <div class="loaddataURL"></div>
    </div>

////////////////// J-Query

function LoadUrl(th, IntWidth, showDivButtonId) {
        $("#Progressbar").show();
        $('.loaddataURL').load(
            "URL",
            DataContent or Form Data
            function (data, status, jqXGR) {
                    //// Here set any thing after loading the url data or form
                $("#Progressbar").hide();
            }
        );

}


How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...