I have some code that looks like this
====================
if (theForm.location1.value < 1000 || theForm.location1.value > 9999){
alert("Invalid postcode. A valid postcode has 4 numbers"
theForm.location1.select()
return(false);
}
if (theForm.location2.value < 1000 || theForm.location2.value > 9999){
alert("Invalid postcode. A valid postcode has 4 numbers"
theForm.location2.select()
return(false);
and so on
=====================
What I want to do is make section of code to tidy it up so that it looks something like this...but it looks very wrong...any thoughts?
=======================
for(count = 1; count < 10;count++){
if ("theForm.location" + count + ".value < 1000 || theForm.location" + count + ".value > 9999"
{
alert("Invalid postcode. A valid postcode has 4 numbers"
//this is the bit where I am stuck...what would this line look like?
//theForm.location + count + .select() looks totally wrong.
theForm.location1.select()
return(false);
}
}
==============
In VBscript it is a breeze, but I am a bit stuck here. Perhaps it can't be done...
Steve Davis
hey.you@hahaha.com.au
====================
if (theForm.location1.value < 1000 || theForm.location1.value > 9999){
alert("Invalid postcode. A valid postcode has 4 numbers"
theForm.location1.select()
return(false);
}
if (theForm.location2.value < 1000 || theForm.location2.value > 9999){
alert("Invalid postcode. A valid postcode has 4 numbers"
theForm.location2.select()
return(false);
and so on
=====================
What I want to do is make section of code to tidy it up so that it looks something like this...but it looks very wrong...any thoughts?
=======================
for(count = 1; count < 10;count++){
if ("theForm.location" + count + ".value < 1000 || theForm.location" + count + ".value > 9999"
alert("Invalid postcode. A valid postcode has 4 numbers"
//this is the bit where I am stuck...what would this line look like?
//theForm.location + count + .select() looks totally wrong.
theForm.location1.select()
return(false);
}
}
==============
In VBscript it is a breeze, but I am a bit stuck here. Perhaps it can't be done...
Steve Davis
hey.you@hahaha.com.au