What I am trying to do is check to see what state code the end user puts in. If the state code (IL, IA, for example) matches any of the 50 state codes for USA, then the code will "turn on" validation routine for the zipcode form field-making the zipcode required. Otherwise the zipcode field can be skipped.
I'm using Javascript as follows:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin ---->
// Preload images
var empty = new Image(); empty.src = "fieldempty.gif";
var email = new Image(); email.src = "emailerror.gif";
var haveerrors = 0;
function showImage(imagename, imageurl, errors) {
document[imagename].src = imageurl;
if (!haveerrors && errors) haveerrors = errors;
}
function validateFormS(f) {
haveerrors = 0;
(f.st.value == "") // validate state
? showImage("stateerror", "fieldempty.gif", true)
: showImage("stateerror", "blankimage.gif", false);
I will need one for Zip code.
(f.zip.value == "") // validate zip code
? showImage("ziperror", "fieldempty.gif", true)
: showImage("ziperror", "blankimage.gif", false);
If the value for st is one of the 50 states then the f.zip.value section of code must be activated.
thank you.