Flash Script – Form Validation in Flash

By Georgina Laidlaw

If you create a form for your site, you should, of course, check for errors in user input before the form can be successsfully submitted.

This simple tutorial will show you how to check whether a user-entered number is actually a number, not some other character. Download the sample files here.

1. Create an empty text box, and give it the variable name "txt".

2. Create a button of your choice, right click the button, and select "actions". Insert this action:

on (release) 
txt="Not Number";
txt="Is Number";

3. That’s it! Now, take it for a spin! Enter a letter or number into your form, and see it function.

Here’s how it works. If any letter appears in text box, int() returns 0, otherwise, int returns the entered number. Simple!

No Reader comments



Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Instant Website Review

Use Woorank to analyze and optimize your website to improve your website to improve your ranking!

Run a review to see how your site can improve across 70+ metrics!

Get the latest in Front-end, once a week, for free.