/ Published in: ActionScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/*************** * * INIT FORM * **************/ form = { }; /*************** *** RADIOS **************/ // obj : {radios:Array, value:String} function initRadio(obj:Object) { for (var i = 0; i < obj.radios.length; i++) { r = obj.radios[i]; r.value = i; r.onPress = function () { // init all radios for (var j = 0; j < obj.radios.length; j++) obj.radios[j].gotoAndStop(1); this.gotoAndStop(2); obj.value = this.value; } } } // init //form.civ = {radios:[radio_civ_1, radio_civ_2], value:""}; //initRadio(form.civ); /*************** *** FIELDS **************/ // obj : {field:TextField, pass:Boolean, default_value:String, value:String} function initField(obj:Object) { f = obj.field; f.text = obj.default_value; f.onSetFocus = function() { if(this.text == obj.default_value) this.text = ""; if(obj.pass) this.password = true; } f.onKillFocus = function() { if(this.text == "") { this.text = obj.default_value; this.password = false; obj.value=""; } else obj.value = this.text; } } // init //form.name1 = {field:txt_name1, default_value:"VOTRE PRENOM", value:""}; //initField(form.name1); /// CHECK MAIL function isMail (mailType:String):Boolean { var t:String = mailType; var tmpArray:Array = t.split("@"); if (tmpArray.length != 2) return; var tLen:Number = tmpArray[1].length; var tmpChar = tmpArray[1]; var tmpCharZero = tmpArray[0].length if (tLen<2 || tmpCharZero<2) return; for (var i:Number = tLen; i>0; i--) { if (tmpChar.charAt(i) == ".") { newPoint = i; afterDot = tmpChar.substr(newPoint, tLen); (afterDot.length>=2) ? (myValue=true) : (myValue=false); break; } } return myValue; }