xgd
06-15-2008, 07:28 AM
Hi all,
i have this email form that works with as2 but i need it to work with as3. If someone is bothered please help.
AS2 code:
email_txt.restrict = "a-z_.@0-9";
email_txt.maxChars = 40;
name_txt.restrict = "A-Za-zÁáÉéêíÍãõç ";
name_txt.maxChars = 40;
comments_txt.restrict = "0-9A-Za-zÁáÉéêíÍãõç!?.+\- ";
comments_txt.maxChars = 200;
comments_txt.onSetFocus = function()
{
status_txt.text = '';
}
email_txt.onSetFocus = name_txt.onSetFocus = phone_txt.onSetFocus = comments_txt.onSetFocus;
status_txt.text = 'All fields required';
submit_btn.onRelease = function()
{
var email = email_txt.text;
var namee = name_txt.text;
var comment = comment_txt.text;
// are all the fields filled?
if (namee == '') {
status_txt.text = "You need to fill in your Name.";
return;
}
if (email == '') {
status_txt.text = "You need to fill in your E-mail.";
return;
}
// you should also validate the email address
if (comment == '') {
status_txt.text = "Please, don't forget your Comment!";
return;
}
// yes, all fields filled
sendEmail(name, email, comment);
// sending data...
status_txt.text = "Processing mail form...";
// prevent submitting again by disabling the button
this.enabled = false;
};
function sendEmail(name, email, comment)
{
var myData = new LoadVars();
myData.name = name;
myData.email = email;
myData.comment = comment;
myData.onLoad = function(ok) {
if (ok) {
status_txt.text = this.message;
} else {
status_txt.text = "There was an error. Try again later.";
}
submit_btn.enabled = true;
};
myData.sendAndLoad('contactform.php', myData, 'POST');
}
i have this email form that works with as2 but i need it to work with as3. If someone is bothered please help.
AS2 code:
email_txt.restrict = "a-z_.@0-9";
email_txt.maxChars = 40;
name_txt.restrict = "A-Za-zÁáÉéêíÍãõç ";
name_txt.maxChars = 40;
comments_txt.restrict = "0-9A-Za-zÁáÉéêíÍãõç!?.+\- ";
comments_txt.maxChars = 200;
comments_txt.onSetFocus = function()
{
status_txt.text = '';
}
email_txt.onSetFocus = name_txt.onSetFocus = phone_txt.onSetFocus = comments_txt.onSetFocus;
status_txt.text = 'All fields required';
submit_btn.onRelease = function()
{
var email = email_txt.text;
var namee = name_txt.text;
var comment = comment_txt.text;
// are all the fields filled?
if (namee == '') {
status_txt.text = "You need to fill in your Name.";
return;
}
if (email == '') {
status_txt.text = "You need to fill in your E-mail.";
return;
}
// you should also validate the email address
if (comment == '') {
status_txt.text = "Please, don't forget your Comment!";
return;
}
// yes, all fields filled
sendEmail(name, email, comment);
// sending data...
status_txt.text = "Processing mail form...";
// prevent submitting again by disabling the button
this.enabled = false;
};
function sendEmail(name, email, comment)
{
var myData = new LoadVars();
myData.name = name;
myData.email = email;
myData.comment = comment;
myData.onLoad = function(ok) {
if (ok) {
status_txt.text = this.message;
} else {
status_txt.text = "There was an error. Try again later.";
}
submit_btn.enabled = true;
};
myData.sendAndLoad('contactform.php', myData, 'POST');
}