Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form checking 1

Status
Not open for further replies.

xscape

Programmer
Apr 18, 2001
144
GB
Hi,

I'm using Flash 5, and I've created a form for users of the website to fill in, then it posts to an ASP page for emailing to me. I've set up the ASP to check that certain fields are completed, such as name, email address etc.

However, I'd prefer a sort of alert box that appears within the Flash if someone tries to press the 'send' button without filling all the parts (like you can use Javascript alerts for HTML form checking). Any help would be great!

Thanks!
 
You can trigger a Javascript alert from Flash too. Use the same javascript code as you would for an HTML form and use something like this attached to your submit button...

on(release){
if(emailField=""){
getURL("javascript:alertMessage('Please fill in email field')");
}

Slainte

 
Ahh, now that makes sense! However... I've tried this a few different ways and it doesn't seem to want to trigger the alert. My Flash variable is 'email'. Here's the code I'm using:
[tt]
on (release) {
if (email == "") {
getURL ("javascript:alert('Please enter your email address')");
}

else {
getURL ("ContactMailer.asp", "", "POST");
}
}[/tt]

The thing is, the prompt works perfectly because I tried putting it within the [tt]else[/tt], and the other getURL within the [tt]if[/tt] just to test if it was working. The only problem I can see here is that 'name' appears to have some sort of default value? Any ideas!?

Thanks!
 
Yeah - default value for every variable is undefined or FALSE. Before you run the script you should initialise the variable to "" or check the condition as if(email). Slainte

 
Fantastic stuff! Just got it all working very nicely now! Thanks a lot wangbar - have a big shiny pink star for your troubles! :)

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top