Skip to content

Instantly share code, notes, and snippets.

View mrmanc's full-sized avatar

Mark Crossfield mrmanc

View GitHub Profile
@mrmanc
mrmanc / label-fix-regexs
Created June 14, 2012 22:07
Regexs to fix forms disconnected labels
I've been irritated with the hundreds of label tags in our sites with no 'for' attribute. This leads to forms where clicking the label does not put focus into that field. So I've written these operations to bulk fix this problem.
There are two steps, because if you've not used 'for' attributes, you probably don't have 'id' attributes on your form fields. So I've extracted the 'name' attribute from the form field and name-spaced it. Caution: if you have more than one form on the page you might end up with two elements with the same 'id' attribute, which would be improper.
So this:
<label>Forename</label>
<input name="forename">
becomes:
<label for="auto-generated-id-forename">Forename</label>
@mrmanc
mrmanc / gist:2892153
Created June 7, 2012 22:43
Pig On Wheels
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsSAAALEgHS3X78AAAACXZwQWcAAAAwAAAAMADO7oxXAAAObklEQVRo3r1aa2wcVZb+zq1XVz9sx3bHr3ZiYidxnIkDIZBkwSQQCIlmmCEwCAmkFdrdH/BjJdjfaFestBLSSmj4sT+Y3dXsrjQz2mgYBCKgmQDZyImzyGuCH0lMguMMcdyO3R33w13dXY979kdVOx0nTmwec6VSucvVdc93vu/cc86tJmZ+Cn/mwYD0TwABwj99u6H+8LYC8A0GAHgAyidPbgpNTj6Ajo5h7Np1nnRdBiBWDeSHAFAxGlJK9jwvRkQtRBQjIteyrLT88sunwrncYzwz82NMTByXu3Ydpe7uJBFhtSDoe5IQA2AGmJmJy2XNLpUiwjT/QlXVx4QQCQAGACmZc3J83FA//7wGMzMAEcMwpri9/UPq6zuBpqb8amT1XQEwA9IrlXROJpswN9cl8vlOx/NasG3bWqO5uZ2ItNtSlMkAn3wCXLwIIgITuYhExri7+z166KFhmKZLK5DVSgFwEHiVoIMEpJtOxzAxsV1cv/6wKJe3EPMaz/MUd9MmGFu3goS480Pn54EPPwSmp/0ZAECIAurrT/L9939A27f/KXjGsg9aCQD2CgWVjh/fQ0J42L//fx3XVeTZszvVubmfKI7TDWadADAzrEgERl8f1HD47l4BgEuXgFOngOvXgVIJxOxf17Rr3Nr6MT388Cdob59fTlZ3C2KWgHQ//XSXPj7+tyBybGaTNK1bt6x9gjnku8F/rud5kPE4lCXGMzOklBBCIAhUBGyCm5qApibANIFMxmfF80CO04RvvvlLvPfebu7qeg99ff9HsZi9FMRdAdjnzzepExM/JylNBkLa5OTL1Nqqk2/NTTe7zKCamptmmJ+fx/vvv4+xsTG0trbimWeeQUdHx40bDA