HTML5 E-Mail Validation

Validating email addresses is a very unthankful business. Whatever you do, you’re doing it wrong. If you follow the spec, users complain about false positives, if you don’t, they’ll complain about false negatives. And you can’t even blame them – in most contexts, “foo@bar” is not a valid address, according to the standard it is (consider “foo@localhost”).

As usual, being pragmatic and having a good testsuite helps. As part of the jQuery Validation plugin, a somewhat comprehensive testsuite came together. The implementation for that is here. That expression wasn’t written by hand, but compiled. Scott González has the tools for that.

With that in mind, what are the html5 email validations doing? While I don’t know what they’re testing against, Schalk Neethling looked up the implementations for Chrome and Firefox. It would be interesting to run those implementations against the testsuite above, and see if there are problems. Anyone interested in helping with that?

Fighting Brook’s Law

You prolly heard of Brook’s Law before:

adding manpower to a late software project makes it later

While that is, in Brook’s words, an “outrageous oversimplification”, it captures a lot value. And as with most things, taking a step back by generalzing it, yields some interesting results.

Consider the recommendation (see for example slide 46 here) that anyone with experience with venture capital funding will give you: Only take funding when you don’t need it. In this context, you should use funding to grow a company that already works. If you need money just to keep it running, you might as well stop.

Kind of similar to Brook’s Law, isn’t it? But still, its kind of unintuitive. Let’s try another example:

Consider that you live in a time where you need children to take care of you eventually, when you can’t take care of yourself anymore. Was the reality not that long ago. In that context, would you start making children the moment you actually need them? Nope, its just Chuck Testa you’d start two or three decades before that.

Luckily for us, in software projects we don’t have to plan decades ahead. But the lesson should be clear: to fight Brook’s Law, add people to your project when you can, not when you need to.

Here’s the post as a gist, you’re welcome to improve it.

Git fu: Bash addons

My .bash_profile, sourcing git-completion.bash to get autocomplete for git itself and git-flow-completion.bash to get autocomplete for git-flow, along with two single character shortcuts for the most common shortcuts (s for `git status`, d for `git diff`). And my .gitconfig, among regular config and customizing colored output also defining a bunch of aliases:


(If you’re reading the feed, check this gist).

The export line configures bash to show the current directory (full path!), and, if in a repository, the repository type and current branch, looking something like this: ~/dev/qunit [git:master] $
For that to work, `vcprompt` needs to be installed. If you’re using homebrew:

`brew install vcprompt`

The last line in the .bash_profile overrides the `git` command to point at hub, which wraps `git` to provide a few additional commands that make it easier to work with GitHub projects. Among others, it infers projects based on the current git repository and its remotes, powering the git-fork alias, which I use whenever I test and merge pull requests. Say someone named `beefheart` sends a pull request for jquery/qunit. All I do to get his remote is this:

`~/dev/qunit [git:master] $ git fork beefheart`

So much easier then trying to put together the correct .git URL for his fork, then wrapping that with the right invocation of `git remote add -f`.

Other aliases I use all day:

  • `git cm “Message 123″` to commit all updated files without having to launch an editor
  • `git br` and `git co` to create, switch and delete branches
  • `git lp` to see commits with diffs
  • `git lg` to see a kind-of tree view of commits – will show the commits a merge commit added directly after that merge commit, instead of the usual chronological order of `git log`. Very useful to review a banch of merges.
  • `git undo` to revert bad merges
  • `git co .` to revert all changed files

Some more git related tools are provided by git-extras, where I now use git-changelog to create the release notes for QUnit.

I use iTerm 2 on OSX, if nothing else, for the ability to easily display multiple terminals side by side.

If you use ZSH, apparently you can get a lot of this bundled via oh-my-zsh.

Release: Validation Plugin 1.9.0

An update for the jQuery validation plugin is available. Most notable is heavily improved compability with HTML5 controls: You can apply validation rules to input types like number, email or url, it’ll get picked up by the plugin if the type matches a rule, and a required attribute (with the argument) also works with both jQuery 1.6+ (prop) and previous versions (attr).

Another change should make the setup of forms with hidden elements easier, these are now ignored by default (option “ignore” has “:hidden” now as default). In theory, this could break an existing setup. In the unlikely case that it actually does, you can fix it by setting the ignore-option to “[]” (square brackets without the quotes).

A few improvements and bug fixes for validation methods landed:

  • Creditcard now accepts spaces between the other valid characters
  • Email doesn’t accept a dot character at the end anymore.
  • The time method (in additionalMethods.js) is now more thorough.
  • A time12h method got added (also in additionalMethods.js), to validate 12-hour times, while the existing time method does 24-hour times.

There also two new localizations, resulting in a total number of 38 localizations. Existing localizations saw various improvements – thanks to everyone who contributed those! Its the only feature where I’m relying completely on contributions, as I can’t verify the correctness of any of the localizations (other then English and German).

Backwards compatibility is still going strong: The plugin should work with anything from jQuery 1.3.x to 1.6.x.

Download this release.

The full changelog:

  • Added Basque (EU) localization
  • Added Slovenian (SL) localization
  • Fixed issue #127 – Finnish translations has one : instead of ;
  • Fixed Russian localization, minor syntax issue
  • Added in support for HTML5 input types, fixes #97
  • Improved HTML5 support by setting novalidate attribute on the form, and reading the type attribute.
  • Fixed showLabel() removing all classes from error element. Remove only settings.validClass. Fixes #151.
  • Added ‘pattern’ to additional-methods to validate against arbitraty regular expressions.
  • Improved email method to not allow the dot at the end (valid by RFC, but unwanted here). Fixes #143
  • Fixed swedish and norwedian translations, min/max messages got switched. Fixes #181
  • Fixed #184 – resetForm: should unset lastElement
  • Fixed #71 – improve existing time method and add time12h method for 12h am/pm time format
  • Fixed #177 – Fix validation of a single radio or checkbox input
  • Fixed #189 – :hidden elements are now ignored by default
  • Fixed #194 – Required as attribute fails if jQuery>=1.6 – Use .prop instead of .attr
  • Fixed #47, #39, #32 – Allowed credit card numbers to contain spaces as well as dashes (spaces are commonly input by users).
As usual:
  • Please post questions to the official Using jQuery Plugins Forum, tagging your question with (at least) “validate”. Keep your question short and succinct and provide code when possible; a testpage makes it much more likely that you get an useful answer in no time.
  • Please post bug reports and other contributions (enhancements, features, eg. new validation methods) to the GitHub issue tracker

Enjoy!