OK, i gotcha now... umm, well, I'm not a js expert by any stretch of the imagination, but I scouted around and think I mighta found something that might lead you to what you want (it validates valid state entry, but it should be easy to redo for your purposes, found at: http://developer.netscape.com:80/docs/books/idg/jsbible/jsbible37.pdf
// States array
var USStates = new Array(51)
USStates["AL"] = "ALABAMA"
USStates["AK"] = "ALASKA"
USStates["AZ"] = "ARIZONA"
USStates["AR"] = "ARKANSAS"
USStates["CA"] = "CALIFORNIA"
USStates["CO"] = "COLORADO"
USStates["CT"] = "CONNECTICUT"
USStates["DE"] = "DELAWARE"
USStates["DC"] = "DISTRICT OF COLUMBIA"
USStates["FL"] = "FLORIDA"
USStates["GA"] = "GEORGIA"
USStates["HI"] = "HAWAII"
USStates["ID"] = "IDAHO"
USStates["IL"] = "ILLINOIS"
USStates["IN"] = "INDIANA"
USStates["IA"] = "IOWA"
USStates["KS"] = "KANSAS"
USStates["KY"] = "KENTUCKY"
USStates["LA"] = "LOUISIANA"
USStates["ME"] = "MAINE"
USStates["MD"] = "MARYLAND"
USStates["MA"] = "MASSACHUSETTS"
USStates["MI"] = "MICHIGAN"
USStates["MN"] = "MINNESOTA"
USStates["MS"] = "MISSISSIPPI"
USStates["MO"] = "MISSOURI"
USStates["MT"] = "MONTANA"
USStates["NE"] = "NEBRASKA"
USStates["NV"] = "NEVADA"
USStates["NH"] = "NEW HAMPSHIRE"
USStates["NJ"] = "NEW JERSEY"
USStates["NM"] = "NEW MEXICO"
USStates["NY"] = "NEW YORK"
USStates["NC"] = "NORTH CAROLINA"
USStates["ND"] = "NORTH DAKOTA"
USStates["OH"] = "OHIO"
USStates["OK"] = "OKLAHOMA"
USStates["OR"] = "OREGON"
USStates["PA"] = "PENNSYLVANIA"
USStates["RI"] = "RHODE ISLAND"
USStates["SC"] = "SOUTH CAROLINA"
USStates["SD"] = "SOUTH DAKOTA"
USStates["TN"] = "TENNESSEE"
USStates["TX"] = "TEXAS"
USStates["UT"] = "UTAH"
USStates["VT"] = "VERMONT"
USStates["VA"] = "VIRGINIA"
USStates["WA"] = "WASHINGTON"
USStates["WV"] = "WEST VIRGINIA"
USStates["WI"] = "WISCONSIN"
USStates[“WY”] = "WYOMING"
// input value is a U.S. state abbreviation; set entered value to all
uppercase
// also set companion field (NAME="<xxx>expand") to full state name
function isUSState() {
var inputStr = gField.value.toUpperCase()
if (inputStr.length > 0 && USStates[inputStr] == null) {
var msg = ""
var firstChar = inputStr.charAt(0)
if (firstChar == "A") {
msg += "\n(Alabama = AL; Alaska = AK; Arizona = AZ;
Arkansas = AR)"
}
if (firstChar == "D") {
msg += "\n(Delaware = DE; District of Columbia = DC)"
}
if (firstChar == "I") {
msg += "\n(Idaho = ID; Illinois = IL; Indiana = IN; Iowa
= IA)"
}
if (firstChar == "M") {
msg += "\n(Maine = ME; Maryland = MD; Massachusetts =
MA; Michigan = MI; Minnesota = MN; Mississippi = MS; Missouri = MO;
Montana = MT)"
}
if (firstChar == "N") {
msg += "\n(Nebraska = NE; Nevada = NV)"
}
alert("Check the spelling of the state abbreviation." + msg)
gField.focus()
gField.select()
return false
}
gField.value = inputStr
var expandField = eval("window." + gFrame.name +
".document.forms[0]." + gField.name + "expand")
expandField.value = USStates[inputStr]
return true
}
<cut from the document>
The function assumes that the user tried to enter a valid state abbreviation, but
either had incorrect source material or momentarily forgot a particular state’s
abbreviation. Therefore, the function examines the first letter of the entry. If that
first letter is any one of the five identified as causing the most difficulty, a legend
for all states beginning with that letter is assigned to the msg variable (this would
be a great place for a Navigator 4 switch construction). An alert message displays
the generic alert, plus any special legend if one has been assigned to the msg
variable. When the user closes the alert, the field will have focus (except for a
Navigator 3 bug in UNIX platforms) and its text selected. The function returns
false at this point.
If, on the other hand, the abbreviation entry is a valid one, the field is handed
the uppercase version of the entry. The script then uses the two global variables
set in validate() to create a reference to the expanded display field (whose name
must always be the same as the entry field, plus “_expand”). That expanded
display field is then supplied the USStates array entry value corresponding to the
abbreviation label. All is well with this validation, so it then returns true.
You can see here that the so-called validation routine is doing far more than
simply checking validity of the data. By communicating with the field, converting
its contents to uppercase, and talking to another field in the form, a simple call to
the validation function yields a lot of mileage.