jQuery plugin to associate label “for” attribute with form controls that have dynamic id’s

For whatever reason, you can’t associate your labels with your form controls implicitly by wrapping both the label text and the control in a <label> element:

<label>
  Email address: <input type="email" name="email" value="" placeholder="you@example.com"/>
</label>

You’ve had to explicitly state the form control you want the label to be associated with:

<label for="email">Email address:</label>
<input id="email" type="email" name="email" value="" placeholder="you@example.com"/>

…but your framework has other ideas, it decides to commandeer your precious “id” attribute and change it from a simple and beautiful “email” into a junky “dnn_ctr1163_RegistrationForm_email”. *cough* DotNetNuke *cough*, but also *cough* Wicket *cough* and probably a whole load of others.

The problem is now that your label is no longer associated with your form control, and there isn’t a simple fix, like, for example, change the for attribute to read “dnn_ctr1163_RegistrationForm_email”, because the numbers in the id change each time you refresh the page. The ID is dynamic, and you are receiving accessibility black stars.

So, luckily I noticed that often the id will change, but the framework will leave your originally intended id somewhere in there. I’ve written a jQuery plugin to look at label for attributes and try to find the form control you intended to associate it with before your server side framework so rudely changed it.

How to use

  1. Download the plugin and add it to your page
  2. Select the labels you want to re-associate and call the function eg. $(‘label’).fuzzyFor();

TODO

The plugin finds matches by looking for input, select and textarea elements in the document and checking to see if the for attribute in your label element appears in the id attribute of the form control. At the moment if more than one match is found, it just uses the first (which is probably good enough for most). However, it should probably do something a bit more clever and use the form control that is closest to the label (I’m reasoning that you normally put your label’s close to your controls).

1,622 thoughts on “jQuery plugin to associate label “for” attribute with form controls that have dynamic id’s

  1. п»їJust now I came across a helpful guide about generic pills from India. It details WHO-GMP protocols when buying antibiotics. In case you need cheaper alternatives take a look: п»їhttps://kisawyer.us.com/# indian pharmacy paypal. Good info.

  2. п»їLately I discovered a great guide about Indian Pharmacy exports. It covers how to save money for ED medication. If you are looking for cheaper alternatives read this: п»їnavigate here. Might be useful.

  3. Quick question about ordering meds from Mexico. I discovered a verified blog that lists trusted vendors: п»їUpstate Medical. Any thoughts?.

  4. п»їJust now I discovered an interesting page concerning Indian Pharmacy exports. It details WHO-GMP protocols for ED medication. For those interested in cheaper alternatives check this out: п»їpharmacy website india. Worth a read.

  5. Sharing an official analysis on FDA equivalent standards. It explains how to avoid scams for generics. Full info: п»їUpstate Medical.

  6. п»їLately I discovered an interesting page concerning Indian Pharmacy exports. The site discusses the manufacturing standards when buying antibiotics. For those interested in reliable shipping to USA take a look: п»їkisawyer.us.com. Might be useful.

  7. п»їTo be honest I came across a great report concerning ordering meds from India. It details how to save money on prescriptions. In case you need Trusted Indian sources take a look: п»їkisawyer.us.com. It helped me.

  8. FYI a detailed analysis on buying meds safely. It explains quality control for ED meds. Source: п»їpolkcity.us.com.

  9. п»їJust now I stumbled upon a useful guide about buying affordable antibiotics. It details CDSCO regulations for ED medication. In case you need reliable shipping to USA visit this link: п»їhttps://kisawyer.us.com/# top 10 pharmacies in india. Might be useful.

  10. п»їRecently I stumbled upon an informative guide concerning cheap Indian generics. It covers CDSCO regulations for ED medication. If you are looking for cheaper alternatives read this: п»їindian pharmacy paypal. Good info.

  11. I was wondering about buying generic pills online. I discovered a verified archive that compares affordable options: п»їUpstate Medical. Any thoughts?.

  12. п»їActually I stumbled upon an interesting resource concerning safe pharmacy shipping. It explains FDA equivalents on prescriptions. For those interested in cheaper alternatives check this out: п»їhttps://polkcity.us.com/# buying prescriptions in mexico. It helped me.

  13. п»їActually I came across a useful guide about buying affordable antibiotics. It explains WHO-GMP protocols for ED medication. For those interested in cheaper alternatives check this out: п»їhttps://kisawyer.us.com/# best online pharmacy india. It helped me.

  14. п»їTo be honest I stumbled upon an interesting page regarding buying affordable antibiotics. The site discusses CDSCO regulations on prescriptions. If you are looking for cheaper alternatives read this: п»їhttps://kisawyer.us.com/# indianpharmacy com. Hope it helps.

  15. Does anyone know safe Mexican pharmacies. I saw a good post that compares safe places: п»їUpstate Medical. Seems useful..

  16. п»їLately I found a great article regarding cheap Indian generics. It explains CDSCO regulations when buying antibiotics. In case you need factory prices go here: п»їtop 10 pharmacies in india. It helped me.

  17. п»їLately I came across an informative article regarding ordering meds from India. It explains the manufacturing standards for generic meds. In case you need cheaper alternatives go here: п»їtop 10 online pharmacy in india. Worth a read.

  18. Just wanted to share an official guide on cross-border shipping rules. The author describes how to avoid scams for ED meds. Link: п»їUpstate Medical.

  19. п»їLately I stumbled upon a great report regarding ordering meds from India. It covers the manufacturing standards for ED medication. If anyone wants Trusted Indian sources go here: п»їkisawyer.us.com. Worth a read.

  20. п»їActually I found an interesting resource concerning Indian Pharmacy exports. It details CDSCO regulations when buying antibiotics. For those interested in factory prices take a look: п»їhttps://kisawyer.us.com/# Online medicine order. Worth a read.

  21. п»їRecently I found a great resource about ordering meds from Mexico. The site discusses the safety protocols for generic meds. In case you need Trusted pharmacy sources go here: п»їhttps://polkcity.us.com/# mexican pharmacies near me. Worth a read.

  22. Quick question about safe Mexican pharmacies. I discovered a good post that ranks safe places: п»їhttps://polkcity.us.com/# hydrocodone mexico pharmacy. Check it out.

  23. п»їTo be honest I stumbled upon a useful guide regarding buying affordable antibiotics. It explains how to save money for ED medication. In case you need reliable shipping to USA read this: п»їinformation. Good info.

  24. п»їJust now I came across an informative report regarding generic pills from India. The site discusses CDSCO regulations on prescriptions. In case you need cheaper alternatives read this: п»їhttps://kisawyer.us.com/# top 10 pharmacies in india. Might be useful.

  25. Stop overpaying and save cash on meds I recommend checking this report. The site explains prices for generics. Good deals found here: п»їhttps://polkcity.us.com/# online pharmacy mexico.

  26. п»їTo be honest I found a helpful resource about buying affordable antibiotics. It details how to save money for generic meds. In case you need reliable shipping to USA take a look: п»їkisawyer.us.com. Worth a read.

  27. п»їTo be honest I found an interesting article about generic pills from India. The site discusses CDSCO regulations for ED medication. In case you need reliable shipping to USA take a look: п»їmore info. Hope it helps.

  28. Stop overpaying and save cash on meds I recommend reading this archive. The site explains trusted Mexican pharmacies. Discounted options at this link: п»їhttps://polkcity.us.com/# mexican meds.

  29. Quick question about getting antibiotics without prescription. I ran into a good site that compares affordable options: п»їdetails. Any thoughts?.

  30. п»їJust now I stumbled upon an informative resource about cheap Indian generics. The site discusses WHO-GMP protocols for ED medication. If anyone wants Trusted Indian sources take a look: п»їkisawyer.us.com. Worth a read.

  31. п»їJust now I came across an interesting report about Indian Pharmacy exports. The site discusses the manufacturing standards on prescriptions. In case you need factory prices read this: п»їhttps://kisawyer.us.com/# indianpharmacy com. Good info.

  32. Heads up an official overview on cross-border shipping rules. It explains the best shipping methods for generics. Link: п»їUpstate Medical.

  33. п»їJust now I discovered a useful guide about cheap Indian generics. It details the manufacturing standards on prescriptions. If anyone wants Trusted Indian sources take a look: п»їhttps://kisawyer.us.com/# best india pharmacy. Cheers.

  34. п»їTo be honest I discovered an informative guide concerning Indian Pharmacy exports. It details the manufacturing standards for generic meds. If anyone wants reliable shipping to USA take a look: п»їcheapest online pharmacy india. Hope it helps.

  35. п»їRecently I stumbled upon an informative guide about ordering meds from Mexico. It covers FDA equivalents on prescriptions. If anyone wants affordable options go here: п»їuseful link. Cheers.

  36. п»їRecently I discovered an informative resource about generic pills from India. The site discusses how to save money for generic meds. If anyone wants factory prices check this out: п»їmail order pharmacy india. Worth a read.

  37. п»їRecently I found an informative report about buying affordable antibiotics. It explains WHO-GMP protocols for ED medication. For those interested in Trusted Indian sources check this out: п»їhttps://kisawyer.us.com/# indian pharmacy. Hope it helps.

  38. Does anyone know buying generic pills online. I saw a verified archive that lists safe places: п»їhttps://polkcity.us.com/# online pharmacy. Looks legit.

  39. Has anybody tried safe Mexican pharmacies. I saw a decent site that reviews safe places: п»їhttps://polkcity.us.com/# farmacia mexicana online. What do you think?.

  40. п»їTo be honest I came across an informative page about ordering meds from India. It covers the manufacturing standards when buying antibiotics. If you are looking for factory prices go here: п»їwebsite. Good info.

  41. п»їActually I stumbled upon a helpful guide concerning generic pills from India. It covers CDSCO regulations for generic meds. In case you need cheaper alternatives take a look: п»їindian pharmacy. Worth a read.

  42. For those looking to save money on prescriptions I suggest visiting this report. It reveals shipping costs. Huge savings available here: п»їhttps://polkcity.us.com/# mexi pharmacy.

  43. п»їLately I stumbled upon a helpful page regarding ordering meds from India. It covers the manufacturing standards on prescriptions. If you are looking for cheaper alternatives go here: п»їkisawyer.us.com. Good info.

  44. п»їRecently I came across an informative guide concerning ordering meds from India. It details WHO-GMP protocols on prescriptions. In case you need factory prices go here: п»їhttps://kisawyer.us.com/# india pharmacy. It helped me.

  45. Heads up an official analysis on buying meds safely. It explains the best shipping methods for generics. You can read it here: п»їpolkcity.us.com.

  46. I was wondering about ordering meds from Mexico. I ran into a cool blog that lists safe places: п»їhttps://polkcity.us.com/# my mexican pharmacy. Looks legit.

  47. п»їJust now I stumbled upon an interesting article regarding ordering meds from India. It covers WHO-GMP protocols on prescriptions. In case you need factory prices take a look: п»їhttps://kisawyer.us.com/# Online medicine home delivery. Might be useful.

  48. п»їTo be honest I discovered a great guide about ordering meds from India. It covers CDSCO regulations for ED medication. If anyone wants factory prices go here: п»їdetails. Cheers.

  49. п»їLately I found a great resource concerning buying affordable antibiotics. It explains regulations for ED medication. If you are looking for affordable options take a look: п»їhttps://polkcity.us.com/# mexico pharmacy price list. Good info.

  50. п»їRecently I found a useful resource about generic pills from India. It covers WHO-GMP protocols when buying antibiotics. In case you need Trusted Indian sources visit this link: п»їread more. Cheers.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>