/*! Validate - v0.1.0 - 2013-11-12 * https://github.com/jessiehan/form-validate * Copyright (c) 2013 hpp; Licensed MIT */ !function(a){var b={text:function(b){return 0===a.trim(b).length?!1:!0},mobile:function(a){return/^1[3-9]\d{9}$/.test(a)},email:function(a){return/^(?:[a-z0-9]+[_\-+.]?)*[a-z0-9]+@(?:([a-z0-9]+-?)*[a-z0-9]+.)+([a-z]{2,})+$/i.test(a)},date:function(a){var b,c,d=/^([1-2]\d{3})([-/.])?(1[0-2]|0?[1-9])([-/.])?([1-2]\d|3[01]|0?[1-9])$/;return d.test(a)?(b=d.exec(a),year=+b[1],month=+b[3]-1,day=+b[5],c=new Date(year,month,day),year===c.getFullYear()&&month===c.getMonth()&&day===c.getDate()):!1},daterange:function(a,c){var d=!1;if(b.date(a)&&b.date(c)){var e=/^([1-2]\d{3})([-/.])?(1[0-2]|0?[1-9])([-/.])?([1-2]\d|3[01]|0?[1-9])$/,f=e.exec(a),g=e.exec(c),h=new Date(f[1],f[3]-1,f[5]).getTime(),i=new Date(g[1],g[3]-1,g[5]).getTime();i>h&&(d=!0)}return d},price:function(a){return/^[0-9]+.?[0-9]*$/.test(a)},pricerange:function(a,c){var d=!1;return b.price(a)&&b.price(c)&&parseFloat(c)>parseFloat(a)&&(d=!0),d},number:function(a){return/^[0-9]+$/.test(a)},numberrange:function(a,c){var d=!1;return b.number(a)&&b.number(c)&&parseFloat(c)>parseFloat(a)&&(d=!0),d},radio:function(a){return 1===a.find("input:checked").length?!0:!1},checkbox:function(a){return a.find("input:checked").length>0?!0:!1},select:function(a){return a.find("select").val().length>0?!0:!1}};a.fn.validate=function(c){function d(b){var c=!0;b.find("."+g+"["+h+"]").each(function(){e(a(this))||(c=!1)}),c?validCallback():unvalidCallback()}function e(a){var c,d=a.data("type");if(d.indexOf("range")>=0){var e=a.find("input:eq(0)").val(),f=a.find("input:eq(1)").val();c=b[d].call(this,e,f)}else if(d.indexOf("radio")>=0||d.indexOf("checkbox")>=0||d.indexOf("select")>=0)c=b[d].call(this,a);else{var g=a.find("input").val();c=b[d].call(this,g)}return c||a.addClass("error"),c}var f=this,c=c||{},g=c.itemClass||"item",h=c.requireName||"required",i=c.$submitBtn||a("input.submit");validCallback=c.validCallback||function(){},unvalidCallback=c.unvalidCallback||function(){};var j=f.find("."+g+"["+h+"] input,."+g+"["+h+"] select");j.focus(function(){a(this).parents("."+g).removeClass("error")}),j.blur(function(){e(a(this).parents("."+g))}),i.click(function(){d(f)})}}(jQuery);