Skip to content

Instantly share code, notes, and snippets.

View adickson311's full-sized avatar

Andre Dickson adickson311

View GitHub Profile
@adickson311
adickson311 / Months to Years
Last active December 22, 2015 06:19
This is a jQuery utility method I wrote that takes a number representing the number of months and returns a string representation of that number in years and months.
$.monthsToYears = function(months){
var val;
if(months < 12) {
val = months + ' month';
if(months > 1 || months === 0){
val += 's';
}
} else {
var yrs = Math.floor(months/12);
var mo = months%12;
@adickson311
adickson311 / noInput.js
Created February 5, 2015 19:07
Angular directive for preventing user input on a text input box, while allowing them to clear the field with delete.
myApp.directive('no-input', function() {
return {
restrict: 'A',
replace: false,
link: function(scope, el) {
el.on('keydown', function(e){
if(e.keyCode === 8){
el.val('');
el.trigger('change');
} else {