/* Form Validation */ function FV() {} FV.prototype = { YD: YAHOO.util.Dom, YE: YAHOO.util.Event, YA: YAHOO.util.Anim, YC: YAHOO.util.Connect, strength: -1, uidcount: 0, uids: {}, codes: { txt_8901: 'Please enter your name', txt_8902: 'Please enter your email', txt_8908: 'Please enter the name of the establishment', men_8918: 'Please rate this member'}, init: function() { this.YE.on(this.YD.get('txt_8901'), 'blur', function(event) { var e = event || window.event; if (e.keyCode != 9 && this.value.length > 0) { FV.showStatus(FV.validate('txt_8901', this.value, 'txt_8901'), 'txt_8901', FV.codes.txt_8901,'textinput'); } }); this.YE.on(this.YD.get('txt_8902'), 'blur', function(event) { var e = event || window.event; if (e.keyCode != 9 && this.value.length > 0) { FV.showStatus(FV.validate('txt_8902', this.value, 'txt_8902'), 'txt_8902', FV.codes.txt_8902,'textinput'); } }); this.YE.on(this.YD.get('txt_8908'), 'blur', function(event) { var e = event || window.event; if (e.keyCode != 9 && this.value.length > 0) { FV.showStatus(FV.validate('txt_8908', this.value, 'txt_8908'), 'txt_8908', FV.codes.txt_8908,'textinput'); } }); this.YE.on(this.YD.get('men_8918'), 'change', function() { FV.validate('men_8918', this.options.selectedIndex, 'men_8918', true); }); this.YE.on(this.YD.get('men_8918'), 'blur', function() { FV.validate('men_8918', this.options.selectedIndex, 'men_8918', true); }); }, validate: function(t, v, n, sl) { switch(t) { case 'txt_8901': var r = new RegExp(".","gi"); break; case 'txt_8902': var r = new RegExp(".","gi"); break; case 'txt_8908': var r = new RegExp(".","gi"); break; case 'men_8918': if (this.YD.get(n).options[v].value != '') { if (sl) { this.showStatus(true, n, this.codes.men_8918,'menuinput'); } return true; }else{ this.showStatus(false, n, this.codes.men_8918,'menuinput'); return false; } break; } if (r) { if (r.exec(v)) { return true; }else{ return false; } } }, showStatus: function(s, id, m, c) { FV.YD.get('status-'+id).className = 'l'; FV.YD.setStyle('status-'+id, 'opacity', 1); FV.YD.get('status-'+id).innerHTML = ''; clearTimeout(FV.YD.get('status-'+id).statim); FV.YD.get('status-'+id).statim = setTimeout(function() { FV.YD.get(id).className = c; if (s) { FV.YD.get('status-'+id).className = 's'; if (FV.YD.get('strength-'+id)) { FV.YD.get('strength-'+id).style.display = 'block'; FV.YD.get(id).className = c; } }else{ FV.YD.setStyle('status-'+id, 'opacity', 1); FV.YD.get('status-'+id).className = 'f'; FV.YD.get('status-'+id).innerHTML = m; FV.YD.get(id).className = c + ' fail'; } }, 500); return s; }, getType: function(form) { var e = 0; for(i=0;i