Validating Text Using "onKillFocus"
Hello all,
I'm REALLY new at AS so please excuse the 'simple' questions.
Trying to build a quiz that has two entry boxes. The user can only enter a value of 0-3 in each box and the total of the two boxes must add up to 3.
If the user enters a wrong value or they don't add up after the second entry, then I've created movie clips that can be called for each error.
I've figured out that I can use onKillFocus to trigger an event once it has left a field, but that's about as far as I can go.
Is there any syntax help out there, I'm getting lost flipping through my reference manuals!
Thanks,
TC
FlashKit > Flash Help > Flash MX
Posted on: 01-29-2003, 11:57 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Input Text OnKillFocus..
Hi,
I`ve got a 10 text fields set to `input` text on the stage. I want the user to be able to press tab and it moves focus to the next one. At the moment focus is jumping onto other buttons and stuff when tab is pressed..
I`ve got this so far but it`s not working:
Code:
for (i=0; i<=10; i++) {
table["ans"+i].onKillFocus = function() {
Selection.setFocus(table["ans"+(i+1)]);
};
I think it`s because the value inside setFocus() is not in "inverted commas" so how do i get around this?
Updating Text Boxes Using OnKillFocus
I have 4 text boxes. The first 3 are input text boxes and the 4th is a dynamic text box. When the user enters a numerical value in the first box then clicks the second, the onKillFocus adds the numbers from the 3 boxes together and displays the total in the 4th box. The same happens when data is entered into the 2nd and 3rd boxes. Here is my code:
onClipEvent (enterFrame) {
this.income_salary.onKillFocus = function() {
this.income_total.text = "1";
trace("boo");
};
}
The problem im having is that the income_total (4th) box won't update when the function exectues, yet the trace statement executes.
Can anyone help?
[FMX]text Field, OnSetFocus And OnKillFocus
I'm making a form and i want to set a backgroundColor for the textfields onSetFocus and that the backgroundColors dissapear again onKillFocus. So far I have this code
Code:
naam.onSetFocus = function(){
this.background = true;
this.backgroundColor = 0xdddddd;
}
mail.onSetFocus = function(){
this.background = true;
this.backgroundColor = 0xdddddd;
}
naam.onKillFocus = function() {
naam.background = false
};
mail.onKillFocus = function() {
mail.background = false;
};
but to me it seems that there must be a way to combine all this lines of code into one single function or at least two one for the setFocus and one for the killFocus.
Somebody who know how to this?
[FMX]text Field, OnSetFocus And OnKillFocus
I'm making a form and i want to set a backgroundColor for the textfields onSetFocus and that the backgroundColors dissapear again onKillFocus. So far I have this code
Code:
naam.onSetFocus = function(){
this.background = true;
this.backgroundColor = 0xdddddd;
}
mail.onSetFocus = function(){
this.background = true;
this.backgroundColor = 0xdddddd;
}
naam.onKillFocus = function() {
naam.background = false
};
mail.onKillFocus = function() {
mail.background = false;
};
but to me it seems that there must be a way to combine all this lines of code into one single function or at least two one for the setFocus and one for the killFocus.
Somebody who know how to this?
Validating Scroll In MultiLine Text Box
Hi, I have a simple that when pressed moves the multiLine text box to line 31, like so:
on (press) {
info.scroll=31
}
Question:
How can i listen to when the scroll is at line 31 then do something?
for example, something alond the lines of:
if (info.scrollPosition == 31) {
button._visible="true"
}
Validating Multiline Text Field
I'm having problems validating a multiline text field.
Here's my code:
Code:
if(txt.text==""){txt.text="please enter an answer"}else{gotoAndStop(2)};
When I test it, and hit the submit button, it just goes right to second frame, but when I change the text field to a single line field, it works perfectly.
How can I do the same thing to a multiline text field?
Validating Quotation In The Input Text Box
Hi All
I want to validate the content starting and ending with quotation symbol in the input text box, User need to type there content with the quotes (“”) in the input text box. Then i need to validate the user's content with the quotes
Eg. Let take text1 is my input text filed. And my answer is "Adobe"(Answer includes quotes also")
If I do like this
Text1.text = ““Adobe””
Error happens
Can any one suggest me to achieve this.
Thank you
Trouble Validating Input Text
Hi all. Just wondering if anyone can help. I'm trying to validate a text input field for email address only if there is actual text inserted. If the input is left blank then the playhead goes to the "end" frame. If there is an error in the text such as no @ symbol , then the playhead goes to the "error" frame. the problem is that when I enter a valid email, my send button doesn't do anything at all, it seems to become inactive. I can't figure out what the problem is in my code. Could someone help me out? send_pb is my button. Here's my code:
Attach Code
send_pb.addEventListener("click", sendListener);
function sendListener(event:Event) {
if(email.text != "") {
if (email.text.indexOf("@") < 1
|| email.text.indexOf("@") == email.text.length -1
|| email.text.indexOf("@") !== email.text.lastIndexOf("@")) {
gotoAndStop("error")
}
} else {
gotoAndStop("end");
}
}
Edited: 03/08/2008 at 02:20:48 PM by fileslasher
Trouble Validating Input Text
Hi all. Just wondering if anyone can help. I'm trying to validate a text input field for email address only if there is actual text inserted. If the input is left blank then the playhead goes to the "end" frame. If there is an error in the text such as no @ symbol , then the playhead goes to the "error" frame. the problem is that when I enter a valid email, my send button doesn't do anything at all, it seems to become inactive. I can't figure out what the problem is in my code. Could someone help me out? send_pb is my button. Here's my code Try it for yourself if you want. 3 frames, an input text and button on frame1, frame2 labeled error, frame3 labeled end.
send_pb.addEventListener("click", sendListener);
function sendListener(event:Event) {
if(email.text != "") {
if (email.text.indexOf("@") < 1
|| email.text.indexOf("@") == email.text.length -1
|| email.text.indexOf("@") !== email.text.lastIndexOf("@")) {
gotoAndStop("error")
}
} else {
gotoAndStop("end");
}
}
Validating Text In Input Field W/o Trigger
Hello,
I am working on an interactive online application training module using Flash 5.
I have a task which I need to simulate using ActionScript:
1. User types a specific name, e.g. "martin" (lower or upper case) into an input text field (which sits on a screen grab of a window). The name has a fixed length.
2. The name is validated automatically.
NOTE: The user is not required to click a button, e.g. "Submit" for the name to be validated, i.e. there is no trigger!
3. If the name was correctly typed, the play-head is advanced to a new frame (with a new screen grab). Else the user needs to try again.
Could someone please help me out with the ActionScript. Your help will be greatly appreciated.
Validating Input Text - How To Make It Easier....
Hello all,
I am using Flash MX and have created a crossword puzzle. I am trying to reduce the code/time necessary to code it.
Here is what I currently have:
function check_answers(){
one = m1v + m2v + m3v + m4v + m5v + m6v + m7v + m8v + m9v + m10v + m11v;
two = ru1v + ru2v + ru3v + ru4v + m2v + ru5v;
if ((one == "maintenance") && (two =="runway")) {
gotoAndStop("right");
} else {
gotoAndStop("missed");
}
}
Is there an easier way to do this? I have used arrays for other things, but nothing requiring validating multiple var instances. Any help would be greatly appreciated.
Thanks in advance.....
A Little Help With OnKillFocus
hey, here's a snippet of script i have on a contact form.
When the user exits the phone number field, it formats the phone number with the correct punctuation:
Code:
_root.uPhone.onKillFocus = function() {
if(_root.uPhone.text.length==10) {
_root.uPhone.text ="("+ _root.uPhone.text.substr(0,3)+")-"+_root.uPhone.text.substr(3,3)
+"-"+_root.uPhone.text.substr(6,4);
}
}
it works, but with one minor problem... if the user clicks the next field by mouse instead of using the tab key, it doesnt work...
any ideas?
thanks,
-myk
OnKillFocus
I have a situation where I want the focus of a textfield to be removed when a user is outside a certain area. I have a mc.onEnterFrame that checks when the user is gone outside x,y bounds if so then I want to kill the focus of the textfield that had been highlighted by the user. The built in flash function onKillFocus works if the user clicks somewhere else on the stage but I need it to happen when the user is outside the bounds that I set.
Thanks,
OnKillFocus
Hi, TextField has an "onKillFocus" event. Now, I don't want to use it as it is. I'd like to have a listener, just like we have it for onScroller. So what I want is an onKillFocus event acting exacly as onScroller. How can we reach this behavior? Many friends of mine has told me I should use ASBroadcaster and addProperty, but I dont' understand exactly how. It is very important.
Thanks to everybody, GPP
OnKillFocus
Thought I'd ask here:
Any work arounds that any one knows about
I have a text feild that if the user clicks out side of it will killfocus...I also need to do this same thing with a combo box...
I thought of using a mouse even but the user has the option to enter in there own data or select it from the combo box so this would be multiple mouse hits...thanks
mdiline.onSetFocus = function(oldFocus) {
trace("in");
my_cb.open();
};
mdiline.onKillFocus = function(oldFocus) {
trace("out");
Selection.setFocus("someother text");
};
ERRORS:
in
256 levels of recursion were exceeded in one action list.
This is probably an infinite loop.
Further execution of actions has been disabled in this movie.
OnKillFocus For Flash 5?
Hi Guys,
Anobody got a clue on how to envoke a killFokus function for the flash5 player?
Code:
input1.fieldValue.onKillFocus = function (newFocus) {
if(fieldValue ne "") {
_root.goword("fieldValue");
}
}
Any bright thoughts out there?
//pod
OnKillFocus Question
I'm using an onKillFocus on one input field so that once a value is entered, a mathematical function is used on all fields.
The problem I'm having is that upon loading of the movie, the input fields are automatically pre-populated with "_level0.fieldname". If I try to declare a value for the fields in any of the frames, the onKillFocus stops working.
How do I keep the fields from pre-populating with the field name and still have the onKillFocus work?
Thanks in advance.
OnSetFocus, OnKillFocus
I have in stage 3 components. 1 tree component with name treeDir and 2 datagrid listaPoze and listaUpload.
On treeDir and listaPoze onSetFocus and onKillFocus works but on listaUpload doesn't work
I am using the same code on all tree ...
Can someone help me ?
the code for listaUpload (all the code is on the first frame in stage)
listaUpload.onSetFocus = function(of) {
trace(of)
};
listaUpload.onKillFocus = function(of) {
trace(of)
};
OnSetFocus And OnKillFocus
Hi - I'm getting erratic behavior with this and I'm hoping someone with experience can point out what is wrong.
I have a project that is like a "cost of home maintenance" calculating tool. There are 2 columns of 8 Input Text fields each. One column is the Costs and the other is Payments. The user fills in, for example, what the total monthly mortgage cost is, and then fills in their $$ share of that cost they pay. At the end of the list the user clicks a button that totals both columns so they can compare the total cost of maintaining the home vs the total amount that they are contributing.
I need to alert the user whenever they might accidentally put a greater amount for their payment than for the cost of something. What I did was attached a movie clip (error_mc) if the user did this. The user can still get to the Input fields when the error_mc is present or close the error_mc with it's own close button.
The erratic behavior (or one of them) is that if the user corrects the inputs while the error_mc is present, it may refuse to close.
Also, sometimes, if the user closes the error_mc and simply continues to enter numbers, leaving the mistake in place, the error message will not re-appear...usually.
What I WANT to have happen is: if one of the 8 tPay fields is greater than it's corresponding tCost, the error_mc appears and will not close (or will keep opening) until tPay is changed to be less than tCost. Once tPay is less than tCost, error_mc goes away.
Right now it's inconsistent. Can someone please give me some hints on what might be wrong?
Attach Code
// this is only one of the onSetFocus and onKillFocus pairs. There are 8 altogether.
tPay8_1.onSetFocus = function() {
if (tPay8 == "0") {
tPay8 = "";
}
};
tPay8_1.onKillFocus = function() {
if (tPay8 == "") {
tPay8 = "0";
}
};
tCost8_1.onSetFocus = function() {
if (tCost8 == "0") {
tCost8 = "";
}
};
tCost8_1.onKillFocus = function() {
if (tCost8 == "") {
tCost8 = "0";
}
//--------if Pay > Cost then attach the error movie clip ----------------------------
if (tPay8 > tCost8) {
attachMovie ("error1_1", "error_mc", this.getNextHighestDepth, {_x:24, _y:355});
}
};
OnSetFocus Vs OnKillFocus
AS2, from an email form for my website:
instance: from_txt, var: from
the onKillFocus part works great, the onSetFocus does not. The input text has "your name here" typed in to begin with.
Please Help!
from_txt.onSetFocus = function() {
if (from == "your name here") {
from = "";
}
};
from_txt.onKillFocus = function() {
if (from == "") {
from = "your name here";
}
};
Onkillfocus Bug Cannot Figure This Out
Hello everyone,
for the life of me i cannot figure out what i am doing wrong. I honestly think it's a bug but i am clueless, i have used this same exact code before and it works but the onkillfocus does not work unless i go to another text field. the cursor does not go away if i click anywhere else.
the fla and swf are in the directory listed below, any tips and advice would be greatly appreciated. Thanks. This is a flash cs3 project but as 2 code.
Thanks.
http://www.nicolaszein.com/DELETE/onkillfocusbug/
for those who do not want to open the file, here is the entire code below just in case:
Code:
stop();
//==================================================================================
//text effects
var text1:String = "name";
var text2:String = "email";
var text3:String = "message";
input_name.text=text1;
input_email.text=text2;
input_message.text=text3;
// tabIndex
input_name.tabIndex = 1;
input_email.tabIndex = 2;
input_message.tabIndex = 3;
//==============================================================================
input_name.onSetFocus=function() {
if(this.text==text1) {
this.text="";
}
}
input_email.onSetFocus=function() {
if(this.text==text2) {
this.text="";
}
}
input_message.onSetFocus=function() {
if(this.text==text3) {
this.text="";
}
}
input_name.onKillFocus=function() {
if(this.text=="") {
this.text=text1;
}
}
input_email.onKillFocus=function() {
if(this.text=="") {
this.text=text2;
}
}
input_message.onKillFocus=function() {
if(this.text=="") {
this.text=text3;
}
}
OnKillFocus, OnSetFocus, Who The Hell Knows?
What you need to know:
varArray = new Array('name','age','phone','breastSize');
inputArray = new Array('inputname','inputage','inputphone','inputbr eastSize');
boxArray = new Array('boxname','boxage','boxphone','boxbreastSize ');
The script below is in one frame, and the next frame tells Flash to loop back to this frame (2 frame loop).
for(i=0;i<varArray.length;i++){
z=i;
_root[inputArray[i]].onChanged = personalInfo.data[varArray[i]]=_root[varArray[i]];
_root[inputArray[i]].onKillFocus = function(newFocus) {
eval(boxArray[z]).gotoAndPlay('out');
};
_root[inputArray[i]].onSetFocus = function(oldFocus) {
eval(boxArray[z]).gotoAndPlay('in');
_root[varArray[z]] = "";
};
}
What it's meant to do:
When the user interacts with the input textboxes, a corresponding MC will begin to play. Therefore, inputphone.onSetFocus will commence the playing of boxphone....in theory.
What actually happens (the problem):
Everything is executed! Everything!! The moment ANY interaction commences, all lines are executed, for every variable and every instance.
Possible FAQ:
Why have you used z? The use of i for some reason wasn't registering. Although it works fine here: _root[inputArray[i]]
It failed here: eval(boxArray[z])
Can't explain it.
P.S. - Please excuse me for my choice of variables.
OnKillFocus Catch By An Object
Hi,
Maybe it is a very stupid question, but I become mad.
I have create an Object
#initclip
CheptelField.prototype = new MovieClip();
function CheptelField(){
}
//associates a movieclip with my object
// the movie clip contain a texField (myTextfield)
Object.registerClass("cheptelField", CheptelField);
#initclip
now, I would like my object to received the onKillFocus message when the user exit from the textfield (myTextfield). How can I do ?
I have try :
CheptelField.protoype.myTextfield.onKillFocus = function(newFocus){
....
}
yes, I know, it is stupid, but I don't underdant how can I do?
Anyhelps ??
Thank you
TextInput OnKillFocus Not Working
Yo!
How can I make the onKillFocus in this script kill the focus when I click outside the TEXTINPUT and not out of the entire movie? I can kill the focus if I click on a button or something but I'd LIKE this to work like an HTML input!
Code:
var theSearchBox = _root.searchBox.searchbox;
var searchDefault = theSearchBox.text;
theSearchBox.onSetFocus = function() {
theSearchBox.text = "";
}
theSearchBox.onKillFocus = function() {
if(theSearchBox.text == "") {
theSearchBox.text = searchDefault;
}
}
By the way, I've already messed with all that focusManager stuff with no results.
Problem With OnKillFocus Method
Hi! I need some help. It seams that onKillFocus dosent work in external swf file. My actionscript with the inputText are in external swf file loaded in the main swf! Anybody some clues? Thanks
Here`s my script:
newsinput.onSetFocus = function ()
{
if (newsinput_1 == "Newsletter")
{
newsinput_1 = "";
} // end if
}// end function
newsinput.onKillFocus = function ()
{
if (newsinput_1 == "")
{
newsinput_1 = "Newsletter";
} // end if
};
onSetFocus its workin perfect!
Please help me as soon as possible ... i have 2 build something and i dont know what to do ... to start another method or i miss something pls pls pls help! 10x
OnKillFocus Event Is Asleep.
K, werkin on a lil' form and the onKillFocus doesn't want to work. Any ideas?
ActionScript Code:
//POPULATE COUNTRY LISTvar countryList = new LoadVars();countryList.load("../assets/countries.list");countriesBox.addItem('','');countryList.onLoad = function() { var comboCountries = countryList.countries.split(","); for (i=0; i<comboCountries.length; i++) { countriesBox.addItem(comboCountries[i],comboCountries[i]); }};//CLEAR ALL FIELDSfor (i in this) { if (this[i].textWidth != undefined) { this[i].text = ""; }}//SUBMIT ACTIONnext_but.onRelease = function() { var error:Boolean = false; if (username_txt.length<=5 && username_txt.text != "") { error = true; username_error_txt.text = "Must be at least 6 characters."; } else { username_error_txt.text = ""; } if (username_txt.text == "") { error = true; username_error_txt.text = "Required."; } username_txt.onKillFocus = function(newFocus:Object) { trace("killfocus"); if (!checkUsername(username_txt.text)) { error = true; username_error_txt.text = "Username is taken."; } }; if (password_txt.length<=5) { error = true; password_error_txt.text = "Must be at least 6 characters."; } else { password_error_txt.text = ""; } if (password_txt.text == "") { error = true; password_error_txt.text = "Required."; } if (passwordConfirm_txt.text == "") { error = true; passwordConfirm_error_txt.text = "Required."; } else { passwordConfirm_error_txt.text = ""; } if (password_txt.length>5 && passwordConfirm_txt.length>0) { if (password_txt.text != passwordConfirm_txt.text) { error = true; passwordConfirm_error_txt.text = "Passwords do not match."; } } if (email_txt.text == "") { error = true; email_error_txt.text = "Required."; } else { email_error_txt.text = ""; } email_txt.onKillFocus = function(newFocus:Object) { if (email_txt.length>0) { if (!validateEmail(email_txt.text)) { error = true; email_error_txt.text = "Invalid email format e.g:(yourname@somesite.com)"; } else { if (!checkEmail(email_txt.text)) { error = true; email_error_txt.text = "Email address taken, you must use a unique address."; } } } }; if (countriesBox.value == "") { error = true; countriesBox_error_txt.text = "Required."; } else { countriesBox_error_txt.text = ""; } if (checkBox_mc._currentframe == 1) { error = true; checkBox_error_txt.text = "You must agree to the terms and Conditions to continue."; } else { checkBox_error_txt.text = ""; } if (!error) { trace("success"); }};//VALIDATION FUNCTIONSfunction checkUsername(username:String) { var checkUsername:LoadVars = new LoadVars(); checkUsername.username = username; checkUsername.sendAndLoad("../php/checkUsername.php",checkUsername,"POST"); checkUsername.onLoad = function() { if (checkUsername.result == "taken") { return (false); } else { return (true); } };}function checkEmail(email:String) { var checkEmail:LoadVars = new LoadVars(); checkEmail.Email = email; checkEmail.sendAndLoad("../php/checkEmail.php",checkEmail,"POST"); checkEmail.onLoad = function() { if (checkEmail.result == "taken") { return (false); } else { return (true); } };}function validateEmail(email:String) { if (email.length>=7) { if (email.indexOf("@")>0) { if ((email.indexOf("@")+2)<email.lastIndexOf(".")) { if (email.lastIndexOf(".")<(email.length-2)) { return (true); } } } } return (false);}//MONKEY FARTS
[as2] OnSetFocus() And OnKillFocus() Problems
I am having problems with some code that has always worked for me in AS1. And technically it is still working, but the problem is that the focus is immediately placed back after the onKillFocus is executed.
It seems the focus is killed when the mouse is pressed, but then it is immediately placed back once the mouse is released.
Should i use some sort of listener for this?
Please help!
Here is my code:
function setFieldFocus(field, fieldText) {
field.onKillFocus = function(newFocus:Object) {
trace(this._name+" lost focus. New focus changed to: "+newFocus._name);
if (this.text == "" || this.text == fieldText) {
this.text = fieldText
}
}
field.onSetFocus = function(oldFocus:Object) {
trace(this._name+" gained focus. Old focus changed from: "+oldFocus._name);
if (this.text == fieldText) {
this.text = ""
}
}
}
setFieldFocus(name_txt, "Your Name:")
setFieldFocus(email_txt, "Your Email:")
setFieldFocus(company_txt, "Your Company:")
setFieldFocus(phone_txt, "Your Phone:")
THANKS!
Textfield OnSetFocus / OnKillFocus
Sorry everyone, the subject field wasn't big enough to be any more descriptive.
If you run this code it will create 5 textfields:
for(var i = 0; i < 5; i++)
{
createTextField(["txt"+i], i, 0, i*25, 100, 20);
this["txt"+i].type = "input";
this["txt"+i].border = true;
this["txt"+i].onSetFocus = function()
{
this.text = "";
}
this["txt"+i].onKillFocus = function()
{
if(!isNaN(this.text))
{
this.variable = this.text;
}
if(this.variable != null)
{
this.text = "" + this.variable;
}
}
}
No problem so far... but if you type the same number into more than one of the textfields... then click away from all textfields... then select one of the textfields with that number in... all textfields with that number change together
I can't think of any reason why this might be & wondered if anyone else had found the same problem.
Thanks for your help
OnSetFocus & OnKillFocus Tiny Help
I've got an email_form field which has the text "Enter email" set to it.
when the user clicks on the text_form i remove the "Enter email" to "[empty]"
however how can i check if the user has entered something? if so leave it be,
and if Not, text_form should set back to "Enter email".
Impossible Yet Simple Onkillfocus Problem
So i have my site that uses input text fields for my guestbook and contact form, but somehow the onkillfocus does not work properly.
You can test it here:
http://www.nicolaszein.com/index2.html
i thought it was the fact that i was using flash player 9 in exporting, but no, even after changing it to 8 it does not work. Then i tried everything. The weird thing is that when i open tutorials i found online that have the same exact movie clips and code they work but mine won't.
Any ideas guys and girls?
OnSetFocus And OnKillfocus Does Not Work When Loading In Target?
Hello,
I have this strange thing.
When loading an external swf file in a target like so:
loadMovie("exernal.swf", "loadhere");
and loadhere is the instance name of the movie clip where the external.swf is loaded in
the onSetFocus and onKillFocus actionscript in this external.swf do not function anymore.
Is there a solution to this, besides loading it in a level?
Regards,
Micheal
Edited: 01/04/2007 at 03:54:48 AM by Michealnl
Alert Component With OnKillFocus Causes Infinite Loop
I have this script...
txtPPM.onKillFocus = function(txtPPM)
{
import mx.controls.Alert;
Alert.show("blah blah");
};
When my focus shifts away from the txtPPM textfield I get an infinite loop error. I haven't been able to find a successful method to fix this. Any suggetions?
Validating An Email
How do i send an email through using cgi, and also if the user enters an unvalid address is says on screen, "not a valid address"
Validating Checkboxes++++HELP
I am putting a site together and have created a form which send variables to a PHP script.
The send button has actionscript which checks for the fields and states which fields the user has missed etc.
My problem is that I want to check that the user fills at least one of my four check boxes. I have no problems getting radio buttons to work as they all have the same variable name, but with check boxes as each has a different variable name I can only make it work if the user completes all the check boxes, which is no good.
Is there any way of checking that they've completed at least one of the boxes and then ignore them, but if they leave them all unchecked it will state they need to complete at least one.
I will gladly send anyone the source files and php etc, or anything else they need to solve this.
Hope you can help.
Thanks
Jason Dorsett
Validating Email
Hi, I'm building an email submission form in flash (mx) using php and I'd like to know how to check that the contact email given by the user is a valid one, not neccesarily if it is a real one, just if the specified one contains an '@' and an appropriate domain.
At the moment the 'submit' button checks to see that the required fields are filled in, and if so posts the variables to the php script and goes to a thankyou page using this script:
on (release) {
if (name eq "" or email eq "" or message eq "") {
stop();
} else {
loadVariablesNum("email.php", 0, "POST");
gotoAndStop(2);
}
}
Presumably the check for suffixes would have to be in 'if', I'm still getting to grips with mx (flash 5's still a bit engrained) so I don't know if there's a better way to do this in mx.
Any help would be much appreciated.
Validating Flash
Does anyone have know how to include a flash movie in HTML and have it validate as HTML 4.01 transitional?
This has been bugging me for a while and I'd appreciate some help if possible.
Thanks.
DalyCity
Validating An Email - 100 %
This could be tutorial but it is very simple. Originaly my problem was how to validate email. Couldnt find any better script then
if (!TFemail.text.length || TFemail.text.indexOf("@") == -1 || TFemail.text.indexOf(".") == -1)
ok this is fine but her we go to check all other thing that are importat @ and ., domain etc. It could be puted all in one if sentence but i left like it was, because that way i had better overview when you trace sometnihng at some point.
Still possible that sometning still missing to check or could be all in better layout. Hope that someone will grab this and make better and put it back.
*********************** VALIDATION EMAIL - what you neeed ***********************
I have lot of boxes to check in my version, but this is not important. You need one dynamic text box in this case named TFemail and one button that will check on release.
************************ ON release code *********************
on (release){
if (!TFemail.text.length || TFemail.text.indexOf("@") == -1 || TFemail.text.indexOf(".") == -1) {
trace("wrong email!");
}
else if (TFemail.text.indexOf("@") == 0 || TFemail.text.indexOf(".") == 0 || TFemail.text.indexOf("@") ==TFemail.text.length-1 || TFemail.text.indexOf(".") ==TFemail.text.length-1) {
trace("wrong email!");
}
else if (TFemail.text.lastIndexOf(".") < TFemail.text.length-5) {//max domain is .info (-4 but string strarted at 0 that way is -5).
trace("wrong email!");
}
else if (TFemail.text.indexOf("@") == TFemail.text.lastIndexOf(".")-1 || TFemail.text.indexOf("@") == TFemail.text.lastIndexOf(".")-2 || TFemail.text.indexOf("@") == TFemail.text.lastIndexOf(".")-3) {//must be min 3 char between @ and .
trace("wrong email!");
}
else if (TFemail.text.lastIndexOf(".") == TFemail.text.length-2) {//must be min 2 char. after last dot
trace("wrong email!");
}
else {
loadVariablesNum ("http://", 0, "POST");
}
}
Xml Path Not Validating....
Hi all,
I have this code that I need to validate xhtml transitional:
**I have edited this message twice but no code is showing - just look at the line of code fro the validator**
<object type="application/x-shockwave-flash" data="imagens/c.swf?path=imagens/roladas2.swf" width="492" height="394">
<param name="movie" value="imagens/c.swf?path=imagens/roladas2.swf" />
<param name="quality" value="high" />
<a href="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"><img src="imagens/home_roladas_estatica.jpg" width="492" height="394" alt="plug-in do Flash" /></a>
</object>
Here is the w3c validator's info:
Line 20, column 91: cannot generate system identifier for general entity "xmlPath"
.../lentixBase.swf?currentNav=expertise&xmlPath=swf/images.xml" width="504" heig
An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling the reference name, unencoded ampersands, or by leaving off the trailing semicolon (. The most common cause of this error is unencoded ampersands in URLs as described by the WDG in "Ampersands in URLs".
Entity references start with an ampersand (&) and end with a semicolon (. If you want to use a literal ampersand in your document you must encode it as "&" (even inside URLs!). Be careful to end entity references with a semicolon or your entity reference may get interpreted in connection with the following text. Also keep in mind that named entity references are case-sensitive; &Aelig; and æ are different characters.
Note that in most documents, errors related to entity references will trigger up to 5 separate messages from the Validator. Usually these will all disappear when the original problem is fixed.
So it has to do with the xmlpath but I dont know what to do to fix it. I have a file called images.xml that is in the SWF folder...There is a folder inside of the swf folder called 'media' that has all the images used in the flash movie.
Any ideas or is there some sort of fix for this I dont know about?
Does Someone Knows How To Actionscript Validating
Does someone knows how to create a validating that accepts letters only. I mean I am working on a test and one of the exercises required to create a validate for the name that only accepts letters.
Thank you!!!Please help
Validating With This Quiz Example
Working with this example for a related piece of work. But i was wondering how I could successfully go about making sure that if the user enters nothing then it does nothing but tell them to enter a answer?
Quote:
// generalized function to check an answer
function answercheck (q, answer) {
if (findword(eval("q"+q), answer) == true && q1.text != "") {
set("out"+q, "That is correct!");
} else {
set("out"+q, "That is incorrect. Please try again.");
}
// does the actual comparison
// determines if the answer is in the user's response
function findword (input, answer) {
var input = input.toLowerCase();
return input.indexOf(answer) != -1;
}
}
check1.onRelease = function() {
answercheck(1, "anim");
};
check2.onRelease = function() {
answercheck(2, "futurewave");
};
q1 & q2 being where they enter the questions
out1 & out2 being where the answer or response is displayed
and
check1 & check2 being the 'check' buttons.
Any help would be greatly appreciated.
Validating Languages
hi i doing a multi language site with external xml files.
I have problem for validate the current language.
When change section i can get the selected current language.
I explain me?
the fla is attached!
in the first frame of my section movie i put this
PHP Code:
load();
function load() {
if (idioma==0) {
getXML("xml/secciones_en.xml","myData",nextStep);
} else {
getXML("xml/secciones_es.xml","myData",nextStep);
};
}
an in my button
PHP Code:
//language button
on (release) {
idioma = 0
cargar();
}
SOME IDEAS?
tks anyway!
Validating Flash
I want my homepage to automatically hide my flash movie if a user doesn't have flash installed/enabled and in its place, show a jpg.
What is best way to do this?
Validating Sequences
Hi there!
I often use the well known book by Franklin & Makar about Advanced AS2 Scripting.
But, despite the fact they provide excellent samples of validation routines (email validation for example), they do not provide any example of validating sequences for phone numbers.
In North America, we have a xxx xxx xxxx scheme.
In France, it's xx xx xx xx xx.
In Germany, it varies (!!!) : xxxxx xx xx or xxxx xxxxxxx or xxxxx xxxxx
In Great-Britain, xx xxxx xxxx
And so on...
Will somebody could give me tips and syntax examples to write a validation function which will work for many different countries?
(I know that this has something to do with "indexOf"...)
I am not afraid to write as many as twenty different cases !!!
:-)
Many thanks in advance for your help !
Validating A Jpeg
cheers!
i have a little question
is there a way of making flash test if a jpeg is present when trying to load it externaly?
-Dahle
Validating A Form
Ok, basically i have an email form that does this:
- Validates fields if they are not filled in and displays error
- Sends email if it is filled
But... before i put the validator on, it went to a success message, but now it doesn't.
All that you do is fill in name, email, telephone and message and click submit and it emails
Attached is the FLA, if anyone could explain how and why this wont work id be grateful.
http://www.jasonmayo.co.uk/preview/golpys/booking.fla
Ok heres the code...
Form Movie Clip
Code:
onClipEvent(data){
gotoAndStop(2);
}
Actions Frame
Code:
stop();
form.name="";
form.email="";
form.phone="";
form.message="";
Submit Button
Code:
on (release) {
if(form.name == "" ){
gotoAndStop(3);
}
if(form.email == "" ){
gotoAndStop(3);
}
if(form.phone == "" ){
gotoAndStop(3);
}
else {
form.loadVariables("booking_submit.php","POST");
}
}
Validating A Jpeg
cheers!
i have a little question
is there a way of making flash test if a jpeg is present when trying to load it externaly?
-Dahle
Validating Buttons HELP
I load XML and parse it in to 3 arrays
article = new Object();
article.date = new Array(); // holds calendar date
article.msg = new Array(); // holds message
article.link = new Array(); // holds links if any
// OTHER PARSE CODE...
article.date has values for loaded dates [1,17,18]
Then i have this:
// Object constructor (used to create multi-D arrays)
function createDiary (date, msg, link) {
this.date = date;
this.msg = msg;
this.link = link;
}
// Create our main array that will hold all of the XML values
entry = new Array();
// Populate the page array with Diary objects
function populateEntry() {//
for (var k = 0; k < article.msg.length; k++) {//
entry[k] = new createDiary(article.date[k], article.msg[k],
article.link[k] );
// Reference to my calendar that holds dates MC's // Here I'm showing that
1,17 and 18 are selected by going to frame 2
_root.boxHolder.holder["myBox" + entry[k].date].gotoAndStop(2);
// if I use K variable it will assign to tempDate 0,1,2 // if i use
entry[k].date it will take the values from my array
// which would be 1,17,18
_root.boxHolder.holder["myBox" + entry[k].date].tempDate = k;
_root.boxHolder.holder["myBox" + entry[k].date].onRelease = function(){//
I DONT KNOW WHAT TO PUT IN HERE... to validate which button pressed and to
load the appropriate message
FROM my msg array. I've tried a lot of things but cant get the result i
need. I'm not duplicating the dates but attaching them, so
i cant put the code inside of one button. How can i do it from _root???
}
//trace(entry[k].msg);
//trace(entry[k].link);
}
}
Just in case my XML document:
<cal monthID="4">
<date id="1">LALALA</date>
<link>http://www.hotmail.com</link>
<date id="17">Appointment with the dentist at 4:30</date>
<link>aaa</link>
<date id="18">Call Brainvisa Technologies. Speak to Mr. Amit Garg. Phone
number</date>
<link>http://www.hivoltmedia.com</link>
</cal>
Validating Forms In Flash
does anyone know how to validate a form in flash,
i'm submitting data to a cf page via a submit button, which gives an error if i leave a form field blank, so i need a script that validates
the form before i submit, an on focus leave possibly unsure of the exact syntax needed can anyone help pls.
D
|