mootools php faith camera linux


Form Check (Email)

A client today wanted some usability client-side in their contact form. Server-side, the contact form won't send without an email address that is formed with a user and domain that has an mx, mail record in DNS.

Still, I totally understand that client-side checks increase usability...maybe a user just didn't realize that their email address has an at-or-about, @ , symbol in it. So here's a way to easily do this inline without requiring a lot of hoo-ha or external javascript:

if(!$('email').getProperty('value').test('@')) alert('Please use a proper email address');

So, mootools is doing a string test to see if there is an at-or-about symbol in the blank. Here is how it looks incorporated into the <input/> tag:

<input type="text" id="email" name="email" size="25" value="" onblur="if(!$('email').getProperty('value').test('@')) alert('Please use a proper email address');"/>

Last Updated: 2008-09-29 11:45:14
Creative Commons License Jay Johnston is a Zend Certified Engineer in PHP 5 LPI-ID: LPI000102450, Verfication Code: wmnnt56y2k  ... Jay Johnston is certified as LPIC-1 by the Linux Professional Institute