HTML and CSS Reference
In-Depth Information
isNaN() Built-in
Function
The isNaN() built-in
function, which tests
whether a value is not
a number, is the only
function that tests a
numeric value as the
argument. The test uses
the NOT operator and
returns a Boolean value
of true or false.
event handler, onBlur, calls
validSalesAmt() user-defined
function when Calculate
button clicked
Figure 10-18
Table 10-10 shows the general form of the JavaScript statement used to assign a null,
or other, value to a text field object within a form.
Table 10-10 Assignment Statement
General form:
document.formname.textfieldname.value=variable_or_literal
Comment:
where formname is the name of the form; textfieldname is the name of a text field in the form;
value is the attribute; and variable_or_literal is the value assigned to the text field.
Examples:
document.LoanForm.Amount.value=LoanAmt
document.LoanForm.Amount.value=”12500”
document.LoanForm.Amount.value=””
To place the insertion point back in a specific text field in the form, the focus must be
set for that text field. Setting the focus means giving attention to an object. JavaScript uses
the focus() method to give attention to an object. When the focus is set to an object, such
as the Amount text field, the JavaScript statement automatically positions the insertion
point in the text field. Table 10-11 shows the general form of the focus() method.
Table 10-11 focus() Method
General form:
document.formname.objectname.focus()
Comment:
where formname is the name of the form that contains the object; and objectname identifies
the object to which focus should be set.
Examples:
document.LoanForm.Amount.focus()
The first step in creating this validation function is to define the variables that will
be needed. Table 10-12 shows the code to define the variables for the validSalesAmt() and
CalcLoanAmt() user-defined functions.
Table 10-12 Code for validSalesAmt() Function to Validate the Loan Amount
Line
Code
19
var salesAmt
20
var loanAmt
21
var loanRate
22
var loanYears
 
Search WWH ::




Custom Search