internet.com

Go to WebDeveloper Home


hm-v6-139x61.gif

Database Journal: The Knowledge Center for Database Professionals

find a web host with:
CGI Access
DB Support
NT Servers
UNIX Servers
Telnet Access

advanced search
jobs

Get FREE Development Info via your Email!

The Webdeveloper channel
FlashKit
GIF.com
HiermenusCentral
webdeveloper Jobs
Java Boutique
JavaScript.com
JavaScript Source
ScriptSearch
StreamingMedia World
WDJ
WDVL
WebDeveloper.com
WebReference.com
XMLFiles.com

internet.com
Internet News
Internet Investing
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/Marketing
ISP Resources
ASP Resources
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

Search internet.com
Advertise
Corporate Info
Newsletters
E-mail Offers

internet.commerce
Be a Commerce Partner










Library

Jiving with Javascript, Part IV

By Kevin M. Savetz

Now or Later?

Should you bother learning JavaScript now, or is it currently just a toy for experimenters? Should you wait until the final version of the JavaScript interpreter ships before trying to learn the ins and outs of the language? Augustine thinks that now is the time to get a jump start on JavaScripting. "Learn JavaScript right now if you want to capture the market while it is viable--you'll be ahead of the field. If you wait until it is fully functional before you learn it, I think you'll be behind the game," he says. Online tutorials can get you started with the basics of the language, and Internet mailing lists and newsgroups devoted to the topic are already home to thriving communities of developers and experimenters.

Will the serious Web page developer need to understand both Java and JavaScript? Because JavaScript can interact directly with the user anywhere on a Web page (rather than being limited to a single window, as with Java), most Java developers will probably want to learn both. But JavaScript should also be viable as a stand-alone tool for less experienced programmers who want to add interactivity to their Web pages.


Figure 1

A Simple JavaScript Program

<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--- these comments should hide the script from old browsers
function checkNum(str, min, max) {
    if (str == "") {
        alert("Enter a number in the field, please.")
        return false
    }
    for (var i = 0; i < str.length; i++) {
        var ch = str.substring(i, i + 1)
        if (ch < "0" || ch > "9") {
            alert("Enter a number, please.")
            return false
        }
    }

    var val = parseInt(str, 10)
    if ((val < min) || (val > max)) {
        alert("Try a number from 1 to 10.")
        return false
    }
    return true
}

function thanks() {
    alert("Thank you.")
}

// end hiding from old browsers -->
</SCRIPT>
</HEAD>

<BODY>
<FORM NAME="ex5">
Please enter a number from 1 to 10: 
<INPUT NAME="num"
    onChange="if (!checkNum(this.value, 1, 10)) 
             {this.focus();this.select();} else {thanks()}">
</FORM>
</BODY>

Kevin Savetz is author of MBONE: Multicasting Tomorrow's Internet, published by IDG books and waiting patiently on a bookshelf near you. You can visit Kevin's Web page or reach him at savetz@northcoast.com.
Reprinted from Web Developer® magazine, Vol. 2 No. 2 Spring 1996 (c) 1996 internet.com Corporation. All rights reserved.


Web Developer® Site Feedback
Web Developer®
Copyright © 2000 internet.com Corporation. All rights reserved.

Web Developer® Home Over a dozen topics in detail Live Chat Downloads Book and Product Reviews Threaded Discussions How-To/Articles/Links Developer Daily News Subscribe Search Corporate Information Advertise Events Publications internet.com Home