Skip to content

Instantly share code, notes, and snippets.

View davetayls's full-sized avatar

Dave Taylor davetayls

View GitHub Profile
@davetayls
davetayls / jquery.hint.js
Created January 28, 2013 10:05
jquery.hint using placeholder
/**
* @author Remy Sharp
* @url http://remysharp.com/2007/01/25/jquery-tutorial-text-box-hints/
*/
/*jshint curly:false */
(function ($) {
var isInputSupported = 'placeholder' in document.createElement('input'),
isTextareaSupported = 'placeholder' in document.createElement('textarea');
@davetayls
davetayls / String.polyfills.js
Created February 7, 2013 16:42
String Extensions
/**
* Converts a string to Title case
* eg: hello how are you -> Hello How Are You
* @return {String}
*/
String.prototype.toTitleCase = function(){
return this.replace(/\w\S*/g, function(txt){
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
};
given([
"1234",
"^",
"<xss>",
"^",
",",
"' --",
"\""
])
.it('the name should be invalid', function(name){
@davetayls
davetayls / jquery.preventDoubleSubmit.js
Created March 5, 2013 16:23
jquery.preventDoubleSubmit
/**
* A jquery plugin to prevent a form being submitted twice
*
* You'd use this on the form itself
* $('form').preventDoubleSubmit();
*/
;(function($) {
function submitHandler(e) {
var $form = $(this);
@davetayls
davetayls / form-search
Created March 12, 2013 14:17
Cross browser search box styling
@davetayls
davetayls / jquery.enterPress.js
Created March 28, 2013 16:35
jquery.enterPress
/**
jQuery.enterPress
@license The MIT License (MIT)
*/
(function($){
'use strict';
$.fn.enterPress = function() {
return this.keypress(function(e) {
if (e.which == 13) {