Form Validation

I got a problem. My form Validation isn’t working. Actually to be more accurate, the chEmail function works but I also need Flash to check the input fields “first” and “last” to make sure something is entered in there? Am I missing something here or done something wrong? Thanks peeps

Here’s the code related to the validation

function ckName(){
if (formData.first == “”){
errBox.setMessage(“Oop’s, you forgot to fill in your first name”);
return false; }
else {
return true};
}

function ckName(){
if (formData.last == “”){
errBox.setMessage(“Oop’s, you forgot to fill in your last name”);
return false; }
else {
return true};
}

function ckEmail(){
if(formData.submit_by == “”){
errBox.setMessage(“You Must Fill In Your Email Address”);
return false;}
else{
if(formData.submit_by.indexOf(".",0)==-1 || formData.submit_by.indexOf("@",0)==-1){
errBox.setMessage(“Your Email Address Is Not In Correct Form”);
return false;}
else{
return true;}
}

}

a very common mistake, an empty textfield is totally empty in the beginning. That means there is no string in it, not even “”. Put into your first frame the actions:

formData.first = “”
formData.last = “”
formData.submit_by = “”

This will give the textfields an empty string

[AS]
if (!first.length){
errBox=“blah”;
}
[/AS]

Seticus, my code is already on the first frame so where would I place the code u gave me?

Digitalosophy, its not working. I’m 100% sure I did it wrong. LOL HELP!

function ckName(){
if (!first.length){
errBox.setMessage(“Oop’s, you forgot to fill in your first name”);
return false; }
else {
return true};
}

function ckName(){
if (!last.length){
errBox.setMessage(“Oop’s, you forgot to fill in your last name”);
return false; }
else {
return true};
}

function ckEmail(){
if(formData.submit_by == “”){
errBox.setMessage(“You Must Fill In Your Email Address”);
return false;}
else{
if(formData.submit_by.indexOf(".",0)==-1 || formData.submit_by.indexOf("@",0)==-1){
errBox.setMessage(“Your Email Address Is Not In Correct Form”);
return false;}
else{
return true;}
}

}

Also another strange thing is its validating email and last name. Its completely ignoring the “first” name.

are you calling the function your creating? i tried the code i gave you it works.

create a textfield and submit button

give submit these actions
[AS]
on (release) {
if (!first.length){
errBox=“Blah”;
}
}

[/AS]

get it working then trouble shoot your own project. im not sure that you are actually calling the functions. where’s ur submit code?

Here is the script for the fields…

function ckName(){
if (formData.first == “”){
errBox.setMessage(“Oop’s, you forgot to fill in your first name”);
return false; }
else {
return true};
}

function ckName(){
if (formData.last == “”){
errBox.setMessage(“Oop’s, you forgot to fill in your last name”);
return false; }
else {
return true};
}

function ckEmail(){
if(formData.submit_by == “”){
errBox.setMessage(“You Must Fill In Your Email Address”);
return false;}
else{
if(formData.submit_by.indexOf(".",0)==-1 || formData.submit_by.indexOf("@",0)==-1){
errBox.setMessage(“Your Email Address Is Not In Correct Form”);
return false;}
else{
return true;}
}

}

function clrData(){
this.formData.submit_by = “”;
this.email.text = “”;
this.formData.first = “”;
this.firstname.text = “”;
this.formData.last = “”;
this.lastname.text = “”;
this.formData.address = “”;
this.address.text = “”;
this.formData.apt= “”;
this.apartment.text = “”;
this.formData.city = “”;
this.city.text = “”;
this.formData.state = “”;
this.state.text = “”;
this.formData.postal = “”;
this.zip.text = “”;
}

function myOnLoad(success){
errBox.setEnabled(true);
if(success){
errBox.setIcon(“info”);
errBox.setTitle(“Thank You”);
errBox.setMessage(“Thank You for joining the BCBG mailing list.”);
errBox._visible=true;
clrData();
}
else{
errBox.setIcon(“warning”);
errBox.setTitle(“System Error”);
errBox.setMessage(“Oop’s error occured while submitting mailing list data. Please try again.”);
errBox._visible=true;
}
}

function goPostal(){
if(!ckName()){errBox._visible=true;return;}
else{
if(!ckEmail()){errBox._visible=true;return;}
}
errBox.setIcon(“info”);
errBox.setTitle(“Sending Mail”);
errBox.setMessage(“Your Email Is Being Submitted”);
errBox._visible=true;
errBox.setEnabled(false);
formData.sendAndLoad(“http://max.bcbg.com/js/flashmailscript.php”, replyData, “post”);

}

And here I already created a script for empty strings on another layer in the first frame. Sorry If I’m not getting it. Im just thoroughly confused.

formData = new LoadVars();
formData.submit = “flashsubmit”;
formData.email = “”;
formData.first = “”;
formData.last = “”;
formData.address = “”;
formData.apt = “”;
formData.city = “”;
formData.state = “”;
formData.postal = “”;

replyData = new LoadVars();
replyData.onLoad = myOnLoad;

try calling clrData() on load

formData is not in the _root is it…

ok it works. do you have any idea why it checks email, last name, and then first?

Does it? How are you calling your functions?

i have no idea. LOL But I posted an example of it at www.tranism.com/forms3.swf

if u hit submit and get the error message? it means its working cuz I’ve disabled the PHP script server side.

just post the actions of the button

function goPostal(){
if(!ckName()){errBox._visible=true;return;}
else{
if(!ckEmail()){errBox._visible=true;return;}
}
errBox.setIcon(“info”);
errBox.setTitle(“Sending Mail”);
errBox.setMessage(“Your Email Is Being Submitted”);
errBox._visible=true;
errBox.setEnabled(false);
formData.sendAndLoad(“http://max.bcbg.com/js/flashmailscript.php”, replyData, “post”);

}