Skip to content

Category: Thoughts

Phone Validation Using Really Simple Validation Plugin

From past posts you could probably ascertain that I’ve taken quite a liking to jQuery.  Lately I’ve been developing a form for my brother, Karl’s drafting service and have used this handy javascript framework.  There is a jQuery plugin that I’ve been working with called Really Simple Validation that presents a simple, easy-to-use way of validating your forms before submitting them.  It also allows an individual to implement their custom functions for validating your forms.

Karl’s order form required a specific phone number format (xxx-xxx-xxxx).  Unfortunately, Really Simple Validation does not have pre-made phone number validation.  I scoured the internet for such a function to no avail, so I decided to write my own custom function for RSV.  It’s fairly simple and straightforward.  Here is the javascript code:

function phoneValid()
var phoneRE = /^\d\d\d\-\d\d\d-\d\d\d\d$/;
var val = document.getElementById(“phone”).value;

if (!val.match(phoneRE)) {
var field = document.getElementById(“phone”);
return [[field, “Please enter a valid phone number format (xxx-xxx-xxxx).”]];
return true;

The first variable created (phoneRE) is a regular expression and is used to match the sequence of phone number (xxx-xxx-xxxx).  The second variable (val) is the value of the particular form input field that has the id of “phone”.  Below that is a conditional statement that returns an error message if the value of the input field doesn’t match the particular regular expression defined as phoneRE.  If you look within that statement you’ll see “return [[field, “Please enter a valid phone number format (xxx-xxx-xxxx ).”]];”.  This area is required for RSV and will display the message if an error is thrown.  The field variable points to the form input field with the id “phone”.

Now that the function is created you just need RSV to make a call.

onCompleteHandler: myOnComplete,
rules: [

To make this coexist within your form you will have to change “#order_form” to the particular id that you have given to your form.  If you look at the line: “function, phoneValid”, you’ll see where the function we created above is being be called.

That’s it!  For those new to jQuery remember that you need to include the jQuery script and the RSV plugin script as described in the links above.

Leave a Comment

The Science of Miracles


“Thermo-dynamic miracles… events with odds against so astronomical they’re effectively impossible, like oxygen spontaneously becoming gold. I long to observe such a thing.  And yet, in each human coupling, a thousand million sperm vie for a single egg. Multiply those odds by countless generations, against the odds of your ancestors being alive; meeting; siring this precise son; that exact daughter… Until your mother loves a man she has every reason to hate, and of that union, of the thousand million children competing for fertilization, it was you, only you, that emerged. To distill so specific a form from that chaos of improbability, like turning air to gold… that is the crowning unlikelihood. The thermo-dynamic miracle.”Dr. Manhattan, “Watchman”

I just saw an excellent documentary about the city-state of Athens titled: The Greeks: Crucible of Civilization.  It covers the invention of democracy and the people that helped pave the way towards this road.  What I find incredible is that the idea of democracy was not created in the Fertile Crescent or the Nile River Valley where thought had a good chance to flourish, but in a terrain as rugged and unyielding as Greece.  What’s even more interesting is how it came about.

Athens was ruled by an aristocratic class of Greeks that was constantly vying for power.  With the help of Spartan forces, Isagoras gained power and attempted to keep it by banishing those that were a threat to his rule.  Then, by a strange turn of events, the Athenian commoners rise up and successfully retake their city.  The exiles that Isagoras had banished were asked to return and help restore rule back to Athens.  The aristocrat Cleisthenes, who had been deposed by Isagoras, modified the system of government so that decisions were made by districts of Athens rather than the original aristocratic families.  He helped create a government for the people.

The small city-state of Athens goes on to defeat Xerxes and the mighty Persian Empire, fighting for their freedom.  Eventually they become a strong naval power, a place of trade and a harbor for ideas.  Little do these ancient people know how far into the future that their ideas have persevered.

This gets me to thinking how fragile our timeline can be in the shaping of our lives.  If the people of Athens had never risen up or were defeated by Isagoras the idea of democracy may not have even entered our mindset.  How miraculous it is that we live in the society that we do and how lucky (or blessed) we are by the events of the past that have brought about this present.

There is a story in my family about my great-grandmother missing the Titanic and coming over on the Carpathia.  I have seen documentation of her being aboard the Carpathia, but nothing to prove she had a ticket to board the Titanic.  Supposedly, she was in an arranged marriage to a Polish man in the United States that had paid for her trip.  After missing the boat in one of the world’s most tragic events, she arrived to find her fiancee “too old”.   She ended up marrying a Ukrainian miner with the last name, Holodnick (Golodnyuk).

As Dr. Manhattan said, “…a thousand million sperm vie for a single egg. Multiply those odds by countless generations, against the odds of your ancestors being alive; meeting; siring this precise son; that exact daughter…” It’s incredible that you or I even exist right now to experience each other’s company and this world that we inhabit.  One slight change in the timeline, such as your mother falling in love with another man could mean someone else existing.  What if your mother never existed in the first place?

Scientists are working on it, but have yet to discover the exact conditions in which human life was created.  Although the universe is large, what is the probability that complex life forms exactly like ourselves would come to being over millions of years?   What is the probability they would be living in a free society?  What is the probability that they would have the same personalities or that they would even perceive such things the same?  The fact that we exist on this planet is a miracle in itself.

Some days I find myself seeing everything as tasteless and mundane.  I get impatient when things don’t work out the way I wish they would.  I forget how much of a blessing it is that I’m even here.  We should cherish the moments that we have on earth and be thankful that we’re taking part in this experience we call life.  We should be grateful for the country that we live and the freedoms that we have.  One shift in the timeline and we might never have had such a great opportunity and there’s always a chance we could lose it.

1 Comment

jPlayer is My New Best Friend

I’ve been looking at alternatives to Flash for loading and playing sound files for a while now. Any iPhone user out there can tell you that they still do not support Flash even though there a lot of reports out there that Apple and Adobe are working towards an agreement. I’m somewhat impatient and want my audio clips to be as available to everyone as I can make them. Even iPhone users.

Unfortunately in my search I found no other real cross-browser solution except for Flash. I did find jPlayer though.

When developing this blog template I chose jQuery from all the other javascript frameworks out there because of its ease of use and flexibility. jPlayer is a plugin written for the jQuery javascript framework. It does use a hidden Flash file to play the music, but is controlled through javascript. Since I was already fairly familiar with jQuery, I went with this option. Also, the real beauty of jPlayer is the ability to easily style the player using HTML and CSS. Although WordPress offers some audio support, I wanted something that followed the look and feel of my site.

After incorporating jPlayer and testing it out on the iPhone, I was stunned. My mp3 files were opening and playing when I hit the play button. It appears jPlayer also detects Flash support, just like the SWFObject library. I’ve searched the site and tried to figure out the reason for this, but haven’t discovered it yet. I thought maybe it used the SWFObject library. If anyone knows, I’m curious.

So, I found a way to play my sound files over the iPhone and all is good in the kingdom. If you’re looking at ways to get your flash video or mp3 files to display on iPhone, I suggest checking out SWFObject. If you’re looking for a good customizable audio player that works with jQuery definitely visit Happyworm’s jPlayer site.


Relay for Life 2009

I’m doing Relay for Life again this year.  Relay, which is an event put on by The American Cancer Society helps fund Cancer research in hopes that some day we develop a cure for this disease.  I have a family member that is currently battling cancer and I know that I don’t want to see this to continue for him or mankind.  Please help support me by making a donation or joining our Relay Team.  You can access my page here.  I thank you in advance for your warm heart and kind consideration.

Leave a Comment