Posts

Validate Date

Snippet: var msie = window.document.documentMode; /**** * Checks a controls value to see if it is a Date Value or not * * Parameters: * @cntrl - String; the Control ID value * @success - Function(); The Success function to execute * @fail - Function(); The Fail function to execute */ function ValidDate(cntrl, success, fail) { var valid = false; if (msie !== undefined) { var dtString = cntrlIDs[cntrl].value; var date = new Date(dtString); if (!isNaN(date)) { dtString = dtString.replace(/-/g, "/"); // Assumed pattern: MM/dd/CCYY var parts = dtString.split("/") var dd = parseInt(parts[1], 10); // Day Number var mm = parseInt(parts[0], 10); // Month Number var yr = parseInt(parts[2], 10); // Year Number if (dd === date.getDate()

Make CSS Inline

Scenario A client requested the ability to Copy/Paste the content of a report from the website to Word. Background The site in question was a compliance reporting website, where the information was being packaged together with other information to then be presented to the compliance agency.  This process occurred on a monthly, quarterly, and yearly basis. The current process, required the compliance "packagers" to copy the report results to Word and then "format" the contents to look as close to the website rendered format.  This process would consume close to a day, maybe two, pending on how many reports needed to be packaged. Problem After review of the situation, i noticed that the problem was occurring only in IE (Internet Explorer) browsers but not Chrome.  Since this organization was a Microsoft house and IE was the supported browser, they required the fix to be IE compliant. Once the problem was isolated to just IE, I started reviewing the

TSQL - String Concatenation

On current project, I ran into a scenario where I needed to concatenate a series of rows into a single string value.  Nothing major, just concatenate them with a delimiter and return the result.  As all of us Microsoft SQL developer's know and deal with is the lack of a SQL supported function that is able to assist us in this "minor" feature. As this is my knowledge dump for techniques and other methods used for the various platforms, here we go: Construct: The first step is to identify what information you want, the basic's of query design.   SELECT Email FROM Contacts Group By Email Group by is conditional, depending on your situation and how you organize your referential integrity. Stage Next, lets build our environment, not the SProc just the supporting actors in the process. declare @email varchar(max) = '' SELECT @email += Email + ', ' FROM Contacts Group By Email This simply concatenates each of

SQL Porosity - CSV Element Calculation

Image
Background: Recently "walked" into a scenario where a client was storing an variable sized CSV string in a field.  This field held data that would eventually be evaluated as a "pseudo" entity for reporting purposes. Problem Due to the need for performance and reliability, the normal practice of splitting the string into a result set and then performing a SQL Count on the result set, would be overly complex and may cause performance issues as the length is variable  (i.e. varchar(max) ) Solution After reviewing several search queries, which most ended up at my old faithful Stack Overflow .  I came across an approach that is nothing more than Porosity .  For my purpose, it fit the bill very cleanly without overly transitioning a single value into a data-set and then calculating the data-set. Net Result Data-Set : Source: SQL Data - Source Value SQL Data - Comma's Voided Math n -  Len([Field]) m  - Len(Replace([Field], ',', '

Acquiring List of controls - Classic JS

Recently ran into a scenario where I need to use the low-level JavaScript parser, instead of JQuery.  During this venture, I ran across a situation where it would be easier for me to select all the HTML Elements with an ID, assign it to a variable as JSON, and then operate on it from that point. So using my previous short-hand experience with JQuery, I started constructing a similar type of format to be used. *********** JQuery *************** // One line and your done, pretty much var cntrls = $('[id]') // Later on, you simply access the element from the variable var val = cntrls['someID'].value *********** JavaScript *********** // Not so one-liner; put in the DOM.Ready event for JS var cntrlIDs = {} var root = document.getElementById('rootID').querySelectorAll('*'); for (i = 0, n = root.length; i < n; ++i) { var el = root[i]; if (el.id) { cntrlIDs[el.id] = el; } } // Later