/*
Form validation script

Licensed for perspexconsulting.com

Written by Matt Dolan
June 2008

Handles validation for various data types in text input fields.
Set the data type for each <input> tags by setting the 'validation' attribute, e.g.:
	<input type="text" name="salary" validate="currency" />

Requires Prototype 1.6 - http://www.prototypejs.org

Validation types:

ATTRIBUTE	| MEANING
-----------------------------------------------------
text		| Text - anything that's not nothing
date		| Date
integer		| Integer
number		| Number
currency	| Currency
phone		| Telephone
email		| Email
postcode	| UK Postcode

*/


eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([4-8fhjl-rt-zB-Y]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('r F(){6(T.location.href.8(/pexcons/)==-1){U(\'Unlicensed use V F - j contact matt@dolan.me to obtain license\');7 u}5.W=r(){f b=$$(\'form\');v(f c=0;c<b.w;c++){x=u;f a=$(b[c]).X(\'y\');v(4=0;4<a.w;4++){6($(a[4]).Y(\'z\')){x=10;$(a[4]).B(\'11\',5.G.C(5));5.H(a[4])}}a=$(b[c]).select(\'textarea\');v(4=0;4<a.w;4++){6($(a[4]).Y(\'z\')){x=10;$(a[4]).B(\'11\',5.G.C(5));5.H(a[4])}}6(x){$(b[c]).B(\'submit\',5.13.C(5))}}};5.I=r(b){f c=b.D(\'z\');6(c==\'y\'){7 b.h===\'\'}l 6(c==\'J\'){15=(b.h.8(/^(0?[1-9]|[12][0-9]|3[K])[- \\/.](0?[1-9]|1[012])[- \\/.](19|20)?\\d\\d$/)!=-1);16=(b.h.8(/^(0?[1-9]|[12][0-9]|3[K])\\s?(st|nd|rd|th)?\\s?(1d|1e|1f|1g|1h|1i|1j|1k|1l|1m|1n|1o|1p|1q|1r|1s|1t|1u|1v|1w|1x|1y|1z|1A)\\s?(19|20)?\\d\\d$/i)!=-1);1B=(b.h.8(/^(1d|1e|1f|1g|1h|1i|1j|1k|1l|1m|1n|1o|1p|1q|1r|1s|1t|1u|1v|1w|1x|1y|1z|1A)\\s?(0?[1-9]|[12][0-9]|3[K])\\s?(st|nd|rd|th)?\\s?(18|19|20|21)?\\d\\d$/i)!=-1);7(!(15||16||1B))}l 6(c==\'t\'){7(b.h.8(/^-?[0-9.,]+$/)==-1)}l 6(c==\'L\'){7(b.h.8(/^-?[0-9]+$/)==-1)}l 6(c==\'M\'){7(b.h.8(/^-?[^a-zA-Z-.,;\'[]()]? ?-?[0-9., ]+k?$/)==-1)}l 6(c==\'N\'){7(b.h.8(/^\\+?[0-9 ()]+$/)==-1)}l 6(c==\'O\'){7(b.h.8(/^[a-m-9!#$%&\'*+\\/=?^_`{|}~-]+(?:\\.[a-m-9!#$%&\'*+\\/=?^_`{|}~-]+)*@(?:[a-m-9](?:[a-m-9-]*[a-m-9])?\\.)+[a-m-9](?:[a-m-9-]*[a-m-9])?$/)==-1)}l 6(c==\'P\'){7(b.h.8(/^([A-PR-UWYZ0-9][A-HK-Y0-9][AEHMNPRTVXY0-9]?[ABEHMNPRVWXY0-9]? ?[0-9][ABD-HJLN-UW-Z]{2}|GIR 0AA)$/i)==-1)}l{7 u}};5.H=r(b){f c=b.D(\'z\');f a=b.D(\'Q\');switch(c){n\'y\':a=\'o\';p;n\'J\':a=\'o: j q a R J dd/mm/yyyy\';p;n\'L\':a=\'o: j q an L t, e.g. 300\';p;n\'t\':a=\'o: j q a t, e.g. 3.14\';p;n\'M\':a=\'o: j q an amount V M, e.g. £50\';p;n\'N\':a=\'o: j q a N t, e.g. 01234 567890\';p;n\'O\':a=\'o: j q a R O address, e.g. user@domain.com\';p;n\'P\':a=\'o: j q a R UK P, e.g. AB12 3CD\';p}b.setAttribute(\'Q\',a)};5.G=r(b){f c=E.1D(b);c.S.borderColor=(5.I(c))?\'#8E0B51\':\'\'};5.13=r(b){f c=E.1D(b);f a=$(c).X(\'y\');v(4=0;4<a.w;4++){6(5.I($(a[4]))){$(a[4]).activate();a[4].S.1E=\'#8E0B51\';U($(a[4]).D(\'Q\'));a[4].S.1E=\'\';E.stop(b);7 u}}};E.B(T,\'load\',5.W.C(5))};f validator=new F();',[],103,'||||ii|this|if|return|search|||||||var||value||please||else|z0|case|Required|break|enter|function||number|false|for|length|formNeedsValidation|text|validate||observe|bindAsEventListener|getAttribute|Event|MGDValidator|_fieldBlur|_setHint|isInvalid|date|01|integer|currency|phone|email|postcode|title|valid|style|window|alert|of|initialise|getInputs|hasAttribute||true|blur||_formSubmit||shortDate|longDate1|||||||Jan|January|Feb|February|Mar|March|Apr|April|May|Jun|June|Jul|July|Aug|August|Sep|Sept|September|Oct|October|Nov|November|Dec|December|longDate2||element|backgroundColor'.split('|'),0,{}))