Guys, I am working on the code for a contact form in flash. I don't get any errors, but, I can't get the code to do certain things. The code shows the "thank you for inquiry" within the "status" box but it will not show when an e-mail, name, telephone or comments" are not input. Can someone please tell me what I'm doing wrong? Here's the code. Thanks
Code:
bSubmit.onRelease = function()
{
email();
}
function email()
{
var sMessage = "Name: " + tName.text + "\nEmail: " + tEmail.text + "\nPhone: " + tPhone.text + "\nComments: " + tComments.text;
lvSend = new LoadVars();
lvReply = new LoadVars();
lvSend.msg = sMessage;
lvSend.address = "info@test.com";
tName.text = "";
tEmail.text = "";
tPhone.text = "";
tComments.text = "";
lvReply.onLoad()
status.text = "Sending Message...";
{
status.text = "Thank your for your inquiry.";
}
lvSend.sendAndLoad('mail.php', lvReply, 'POST');
}
function formValidationChecks(){
if ((!tEmail.text.length) || (tEmail.text.indexOf("@") == -1) || (tEmail.text.indexOf(".") == -1)) {
status.text = "Please enter a valid E-mail address";
return false;
} else if (!tName.text.length) {
status.text = "Please enter Your Name";
return false;
} else if (!tPhone.text.length) {
status.text = "Please enter Your Telephone";
return false;
} else if (!tComments.text.length) {
status.text = "Please Enter Your Message";
return false;
}
return true;
}
Why would the thank you message show? You are checking to see that the input boxes are filled in. If they aren't then show the text otherwise show the thank you text. Where are you calling formValidationChecks() ? I am guessing it is linked to a button.
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||
Your formValidationChecks() function seems a little off. Try using this instead.
PHP Code:
function formValidationChecks(){ if ((tEmail.text.length == 0) || (tEmail.text.indexOf("@") == -1) || (tEmail.text.indexOf(".") == -1)) { status.text = "Please enter a valid E-mail address"; return false; } else if (tName.text.length == 0) { status.text = "Please enter Your Name"; return false; } else if (tPhone.text.length == 0) { status.text = "Please enter Your Telephone"; return false; } else if (tComments.text.length == 0) { status.text = "Please Enter Your Message"; return false; } return true; }
Can you post the code form mail.php? Also is mail.php in the same directory as the flash file or is it in the directory that the page that has the flash file is in?
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||