jQuery Plugin to Convert Numbers to Words (UK English)

I needed a plugin to convert numbers to words so I started to scour the web for examples.  I couldn’t find anything simple…..or that worked well.  Until I stumbled upon a post by Muhammad Rashid here that seemed to work well….almost.  I’ve made a couple of tweaks and fixes, and decided to create my first jQuery plugin!  So first here’s the Fiddle demo.  It requires the jQuery library to run.  So….

Include a reference to the jQuery library, such as:

Here’s the plugin code.  Copy and paste it into an external file and save it (if you wanted to you can minify it first here):

and here is how we can use it – note that we can only execute it on input text elements:

You can style it like so.  I’ve nested the span inside the div so that the message appears underneath the textbox, and the ‘word conversion’ background width expands with the text: