Monday, April 15, 2024

Javascript From and To datepicker validation

  var now = new Date();

    var month = (now.getMonth() + 1);

    var day = now.getDate();

    if (month < 10)

        month = "0" + month;

    if (day < 10)

        day = "0" + day;

    var dateFrom = '01' + '-' + month + '-' + (now.getFullYear());

    var dateTo = day + '-' + month + '-' + now.getFullYear();

    $('#dateFrom').val(dateFrom);

    $('#dateTo').val(dateTo);

    $('[id*=dateFrom]').datepicker({

        changeMonth: true,

        changeYear: true,

        format: "dd-mm-yyyy",

        language: "tr",

        todayHighlight: true,

        autoclose: true,

        isRTL: true,

        endDate: dateTo

    })

Friday, April 12, 2024

How to find the ID from the control in JAvascript

 $('[id$=hfUserVsRoleValue]').attr('id')


use attr attribute 

How to get the value of dropdown multiselect and shown into label HTML and Javascript

 <select id="ddlBranch" multiple="multiple" class="form-select form-select-sm form-control"></select>


var BrList = [];

 $.each($("#ddlBranch option:selected"), function () {

        BrList.push($(this).text());

    });


$("#lblBranch").text(BrList.join(","));

How to set value of label in HTML and Jquery and how to get value of textbox html

Set Value of label

<label id="lblZone" class="fst-italic fw-medium text-danger">test</label>


 $("#lblZone").text('Test');


get value from textbox

<input class="form-control datepickerIcon" id="dateFrom" type="text" />

$('#lblFromDate').text($('#dateFrom').val());

How to create dropdown with multi select in HTML and javascript and JQuery

<select id="ddlZone" multiple="multiple" class="form-select form-select-sm form-control"></select>


$(document).ready(function () {

    $('#ddlZone').multiselect({

        includeSelectAllOption: true,

        enableFiltering: true,

        maxHeight: 600,

        //dropUp: true,

        buttonWidth: '250px',

        enableCaseInsensitiveFiltering: true,

        onDropdownHidden: function (event) {

            ddlZone_onClientDropDownClosed();

            //GetDashBoardSummary();

        },

        templates: {

            button: '<button type="button" class="form-select multiselect dropdown-toggle btn-sm" data-bs-toggle="dropdown" aria-expanded="false" style=" border: 1px solid #dee2e6; border-radius: 15px;"><span class="multiselect-selected-text"></span></button>',

        },

    });

});