Simple Custom Jquery Datepicker Validator   1 comment

Pulgin :

(function($){
 var maxMonthValue = 12;
 var maxDayValue = 31;
 var noOfDaysInMonth = [0,31,28,31,30,31,30,31,31,30,31,30,31];
 var noOfDaysInMonthForLeapYear = [0,31,29,31,30,31,30,31,31,30,31,30,31];
 function AddDatePickerErrorMessage(id)
 {
     $('#'+id+'Validator').html('Please enter valid date').css('color','red');
 }
 function RemoveDatePickerErrorMessage(id)
 {
     $('#'+id+'Validator').empty();
 }
 function ValidateDateValues(value,id,dpFormat)
 {
     var leapYear = false;
     var getNoOfDaysInPresentMonth = 0;
     var monthValue = 0;
     var dayValue = 0;
     var yearValue = 0;
     if(dpFormat == 'dd-mm-yy')
     {
        monthValue = value[1];
        dayValue = value[0];
        yearValue = value[2];
      }
      else if(dpFormat == 'mm-dd-yy')
      {
         monthValue = value[0];
         dayValue = value[1];
         yearValue = value[2];
       }
       if((monthValue == "" || monthValue == null || monthValue == undefined)
          ||(dayValue == "" || dayValue == null || dayValue == undefined) 
          ||(yearValue == "" || yearValue == null || yearValue == undefined))
       {
          AddDatePickerErrorMessage(id);
       }
       else
       {
          if((monthValue.length > 2 || dayValue.length > 2 || yearValue.length != 4)
            || (parseInt(monthValue) > maxMonthValue || parseInt(dayValue) > maxDayValue)
            || (parseInt(monthValue) == 0 || parseInt(dayValue) == 0 || parseInt(yearValue) == 0))
          {
            AddDatePickerErrorMessage(id);
          }
          else
          {
             leapYear = LeapYearCheck(parseInt(yearValue));
             if(parseInt(monthValue) == 2)
             {
                if(leapYear)
                {
                   getNoOfDaysInPresentMonth = noOfDaysInMonthForLeapYear[parseInt(monthValue)];
                }
                else
                {
                   getNoOfDaysInPresentMonth = noOfDaysInMonth[parseInt(monthValue)];
                }
              }
              else
              {
                 getNoOfDaysInPresentMonth = noOfDaysInMonth[parseInt(monthValue)];
              }
              if(parseInt(dayValue) > getNoOfDaysInPresentMonth)
              {
                 AddDatePickerErrorMessage(id);
              }
          }
      }
 }
 function LeapYearCheck(year)
 {
   return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);
 }
 $.fn.validateDatePicker = function()
 {
   this.each(function(){
   var $input = $(this)[0];
   $($input).keyup(function(){
      var dpId = $input.id;
      var dpFormat = $("#"+dpId).datepicker('option', 'dateFormat');
      var dpValue = $input.value;
      var completeDate = dpValue.split("-");
      if(dpValue != "")
      {
         if(completeDate.length == 3)
         {
            RemoveDatePickerErrorMessage(dpId);
            var monthInDate = 0;
            var dayInDate = 0;
            var yearInDate = 0;
            if(dpFormat == 'dd-mm-yy')
            {
               monthInDate = completeDate[1];
               dayInDate = completeDate[0];
               yearInDate = completeDate[2];
            }
            else if(dpFormat == 'mm-dd-yy')
            {
               monthInDate = completeDate[0];
               dayInDate = completeDate[1];
               yearInDate = completeDate[2];
            }
            var dateForValidation = [monthInDate,dayInDate,yearInDate];
            ValidateDateValues(dateForValidation,dpId,dpFormat);
          }
          else
          {
             AddDatePickerErrorMessage(dpId);
          }
       }
    })
 })
 }
})(jQuery);

Usage :

Html :

<input type="text" class="hasDatePicker" id="dp1" />
<div id="dp1Validator"><div>

Script :

$('.hasDatePicker').datepicker().validateDatePicker();

Posted October 16, 2016 by Vasista Bhargav in Html, Jquery/JavaScript

Enterprise Library 6, Semantic Logging, Part 4 advantages, customising   Leave a comment

Software Engineering

This post continues on from part 3:

Enterprise Library 6, Semantic Logging, Part 3, Getting into the details

In-process / out of process logging
Again, here’s the diagrams showing the difference between in-process and out-of-process logging. (Taken from the EL6 documentation)

In-Process
SLABInProcess

OUT-OF-PROCESS
ELoutOfProcessDiagram

As soon as performance in your logging is required, out-of-process should be used. If you use out-of-process though, deployment of your application is more complicated, 2 separate applications are then required for each target host. (SLAB OUT-OF-PROCESS service must run on the same host as the event sources)

Advantages compared to Enterprise Library Logging Block

  1. live configuration, trace tuning without restarting web apps in the IIS (by OUT-OF-PROCESS)
  2. high performance logging
  3. OUT-OF-PROCESS and distributed software systems support
  4. easy to configure in OUT-OF-PROCESS
  5. no unity dependency
  6. Complicated Logging configuration is no longer required and the web.config, app.config is almost free from EL configurations
  7. Application is free from listeners…

View original post 223 more words

Posted February 16, 2016 by Vasista Bhargav in Enterprise Library

Enterprise Library 6, Semantic Logging, Part 3, Getting into the details   Leave a comment

Software Engineering

This post continues on from part 2:
Enterprise Library 6, Semantic Logging, Part 2, OUT-OF-PROCESS

Keywords
Keywords can be used if in the EventSource and later in the listener to defined groups.

– Keywords must be a number to the power of 2, or 2^X because it is used as a bit array.
– Custom Keywords have to be defined inside your EventSource as a nested class.
– Keywords are logged as a integer, so a mapping is required. (Not Strings!)

And now we can set the listener

This following events are logged:
SLABKeywordResults

You can see that all events with the keyword ControllerAction defined or no keywords defined at all are logged. With this keywords can be used for groups or filters but once you start
defining keywords inside an event source, all events should have at least one keyword defined, if you decide to filter out events using keywords.

View original post 143 more words

Posted February 16, 2016 by Vasista Bhargav in Enterprise Library

Enterprise Library 6, Semantic Logging, Part 2, OUT-OF-PROCESS   Leave a comment

Software Engineering

This blog demonstrates how to log to the database using semantic logging (SLAB) OUT-OF-PROCESS in a MVC4 application.

Follow the instructions as shown in part 1
Enterprise Library 6, Semantic Logging, Part 1, database listener

UPDATE: The service is now available as a NuGet package.

Download and install the OUT-OF-PROCESS service:
http://go.microsoft.com/fwlink/p/?LinkID=290903

Follow the instructions shown here:
http://entlib.codeplex.com/wikipage?title=Entlib6CTPReleaseNotes

Taken from the docs:

 To use the out-of-proc SLAB service, follow these steps: Create an event source class that defines your log messages by extending the EventSource class in the System.Diagnostics.Tracing namespace. Add code to your application that generates log messages by invoking methods in your EventSource implementation. If you want to collect and process log messages out-of-process, download and install the SemanticLogging-svc.exe Windows Service and edit the supplied configuration file (SemanticLogging-svc.xml) to define the event listeners. The block includes an XML schema file (SemanticLogging-svc.xsd) to support editing this configuration file…

View original post 179 more words

Posted February 16, 2016 by Vasista Bhargav in Enterprise Library

Enterprise Library 6, Semantic Logging, Part 1, database listener   Leave a comment

Software Engineering

This is a simple MVC sample which shows how to set up a basic Enterprise Library Semantic Logging (SLAB) application which logs to the database.

Create a simple MVC project

Get the Semantic Logging from nuget:
EL6NugetSemanticLogging

EL6NugetSemanticLoggingDb

These nuget packages adds just 4 new assemblies as shown (No Unity):
EL6NugetSemanticLoggingPackages

Install the scripts to your database:
Scripts can be found here ..packagesEnterpriseLibrary.SemanticLogging.Database.1.0.1304.0scripts

Step 1 Create an EventSource

Step 2 Use the logger in code

Step 3 Consume the logger or add a sink
In Global.asax.cs

Now your finished, your logs can be viewed in the database:

EL6NugetSemanticLoggingTable

Note: Our warning log was not logged due the the sink configuration in the global.asax

Here’s how it work:
SLABInProcess

Source code:
https://github.com/damienbod/MVCEL6DbLogging.git

Enterprise Library 6, Semantic Logging, Part 2, OUT-OF-PROCESS
Enterprise Library 6, Semantic Logging, Part 3, Getting into the details
Enterprise Library 6, Semantic Logging, Part 4 advantages, customising

Links:

http://www.codeproject.com/Articles/602077/InstrumentationpluswithplusSemanticplusLoggingplus

http://entlib.codeplex.com/wikipage?title=Entlib6CTPReleaseNotes

http://blogs.msdn.com/b/agile/archive/2013/02/07/embracing-semantic-logging.aspx

http://channel9.msdn.com/posts/Introducing-Semantic-Logging

http://msdn.microsoft.com/en-us/magazine/cc163437.aspx

View original post 2 more words

Posted February 16, 2016 by Vasista Bhargav in Enterprise Library

Add location in Map   Leave a comment

AviWeb

Please go through this link for add location with name.

http://www.map-embed.com/

map

View original post

Posted February 7, 2016 by Vasista Bhargav in Jquery/JavaScript

jQuery the noConflict() Method   Leave a comment

AviWeb

jQuery and Other JavaScript Frameworks
As you already know; jQuery uses the $ sign as a shortcut for jQuery.

There are many other popular JavaScript frameworks like: Angular, Backbone, Ember, Knockout, and more.

What if other JavaScript frameworks also use the $ sign as a shortcut?

If two different frameworks are using the same shortcut, one of them might stop working.

The jQuery team have already thought about this, and implemented the noConflict() method.

The jQuery noConflict() Method
The noConflict() method releases the hold on the $ shortcut identifier, so that other scripts can use it.

Examples:

$.noConflict();
jQuery(document).ready(function(){
jQuery(“button”).click(function(){
jQuery(“p”).text(“jQuery is still working!”);
});
});

var jq = $.noConflict();
jq(document).ready(function(){
jq(“button”).click(function(){
jq(“p”).text(“jQuery is still working!”);
});
});

View original post

Posted February 7, 2016 by Vasista Bhargav in Jquery/JavaScript