I have a few functions running on my page. The first one is called by an onclick event from a select field this function then calls another function zip() this function runs a small script. If the user leaves a field blank then the function should be recalled by the checkit() function as a validation method it is returning undefined on the second call.. The first call from colorchange() works..
function colorchange(value){
if (value != ''){
document.getElementById('delivery').style.borderColor="#000000";
}
else{
document.getElementById('delivery').style.borderColor="#ff0000";
}
if (value == 'deliver'){
zip();
}
}
function checkit(){
var x=document.forms["pricing_form"]["delivery"].value;
if (x==null || x=="")
{
alert("Please Choose Delivery Method");
return false;
}
if (document.getElementById('delivery').value == 'deliver'){
alert ('deliver');
zipcode = document.getElementById('zip') == '';
if (zipcode == '' || zipcopde == null || zipcode == 'false'){
alert('please enter a valid zip code');
zip();
return false;
}
}
}
function zip(){
var zip = prompt("Ship-To Zip Code", "");
if (zip != null && zip != ''){
document.getElementById('zip').value=zip;
}
alert (document.getElementById('zip').value);
}
I renamed the fields as follows to get this script to function properly
function colorchange(value){
if (value != ''){
document.getElementById('delivery').style.borderColor="#000000";
}
else{
document.getElementById('delivery').style.borderColor="#ff0000";
}
if (value == 'deliver'){
zip_get();
}
}
function checkit(){
var x=document.forms["pricing_form"]["delivery"].value;
if (x==null || x=="")
{
alert("Please Choose Delivery Method");
return false;
}
if (document.getElementById('delivery').value == 'deliver'){
alert ('deliver');
zipcode = document.getElementById('zip') == '';
if (zipcode == '' || zipcode == null || zipcode == 'false'){
alert('please enter a valid zip code');
zip_get();
return false;
}
}
}
function zip_get(){
var zip_entry = prompt("Ship-To Zip Code", "");
if (zip_entry != null && zip != ''){
document.getElementById('zip').value=zip;
}
alert (document.getElementById('zip').value);
}
zipcoPdeatzipcode == '' || zipcopde == null || zipcode == 'false'