Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


User Prompting Functions

Other than soliciting the user for input in the HTML Form, it is possible to use the other methods and properties available to help the user correctly fill out the form. You can use Alert, Confirm, or Prompt boxes, for example, to inform the user of something or to solicit simple input. You can also make use of the status line at the bottom of the Web browser window. The following list identifies the JavaScript functions included in FormChek.js for doing this:

  prompt(s)—Display prompt string s in status bar.
  promptEntry(s)—Display data entry prompt string s in status bar.
  warnEmpty(theField,s)—Notify user that required field theField is empty.
  warnInvalid(theField,s)—Notify user that contents of field theField are invalid.

HTML Form Field Checking Functions

The following functions call some of the more basic functions previously described to directly check whether the contents of a given HTML form field contain valid data of the appropriate type:

  checkString(theField,s,ok_if_empty?)—Check that theField.value is not empty or all whitespace.
  checkStateCode(theField)—Check that theField.value is a valid U.S. state code.
  checkZIPCode(theField,ok_if_empty?)—Check that theField.value is a valid zip code.
  checkUSPhone(theField,ok_if_empty?)—Check that theField.value is a valid U.S. phone number.
  checkInternationalPhone(theField,ok_if_empty?)—Check that theField.value is a valid international phone number.
  checkEmail(theField,ok_if_empty?)—Check that theField.value is a valid email address.
  checkSSN(theField,ok_if_empty?)—Check that theField.value is a valid Social Security number.
  checkYear(theField,ok_if_empty?)—Check that theField.value is a valid year.
  checkMonth(theField,ok_if_empty?)—Check that theField.value is a valid month.
  checkDay(theField,ok_if_empty?)—Check that theField.value is a valid day.
  checkDate(yearField,monthField,dayField,labelString, OKtoOmitDay)—Check that field values form a valid date.
  getRadioButtonValue(radio)—Get checked value from radio button.
  checkCreditCard(radio,theField)—Validate credit card information.

Credit Card Validation Functions

Finally, Netscape’s FormChek.js form validation script collection contains a full set of JavaScripts to check that credit card numbers are well formed for a given credit card. The following list identifies and describes these functions:

  isCreditCard(st)—True if credit card number passes the Luhn Algorithm test.
  isVisa(cc)—True if string cc is a valid Visa number.
  isMasterCard(cc)—True if string cc is a valid MasterCard number.
  isAmericanExpress(cc)—True if string cc is a valid American Express number.
  isDinersClub(cc)—True if string cc is a valid Diner’s Club number.
  isCarteBlanche(cc)—True if string cc is a valid Carte Blanche number.
  isDiscover(cc)—True if string cc is a valid Discover card number.
  isEnRoute(cc)—True if string cc is a valid enRoute card number.
  isJCB(cc)—True if string cc is a valid JCB card number.
  isAnyCard(cc)—True if string cc is a valid card number for any of the accepted types.
  isCardMatch(Type,Number)—True if number is valid for credit card of type.

FormChek JavaScript Collection Example

Along with the FormChek.js JavaScript source file for forms validation, Netscape has a number of sample HTML documents that exercise the JavaScript functions. These functions, and the way they are implemented, provide a good example of ways to create smart HTML forms with JavaScript.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.