It's always been important to the user experience to validate as much as possible on the client. HTML5 goes a long way to this end by giving far greater control over input types. As good as HTML5 input types are, we'll need more. Enter Query Validate. (http://bassistance.de/jquery-plugins/jquery-plugin-validation/)
The Validate plugin is a staple in the jQuery community but there are certain things that will help our mobile implementation. Let's start with automatically adding validation to any page that has a form with a class of validateMe
.
$("form.validateMe").each(function(index, element) { var $form = $(this); var v = $form.validate({ errorPlacement: function(error, element) { vardataErrorAt = element.attr("data-error-at"); if (dataErrorAt) $(dataErrorAt).html(error); else error.insertBefore(element); } }); });
Since it is possible that a page might contain multiple forms, let's just deal with it now by hooking it into every...