Figure 3


JavaScript method to verify input pattern.

function  isAPhoneNumber(entry){
        if (entry) {
                var openParen = entry.substring(0,1)
                var areaCode = entry.substring(1,4)
                var closeParen = entry.substring(4,5)
                var exchange = entry.substring(5,8)
                var dash = entry.substring(8,9)
                var line = entry.substring(9,13)

                if  (
                    (openParen != "(")    ||
                    (!isANumber(areaCode)) ||
                    (closeParen != ")")    ||
                    (!isANumber(exchange)) ||
                    (dash != "-")         ||
                    (!isANumber(line))
                   ){
                        alert("Please enter phone number in the 
                              following format: (123)456-7890")
                }        
        }
}