I’ve got some javascript that’s not working in Safari (Mac) and Firefox (PC, Mac), but is working in IE (PC) and Opera (PC, Mac). This java is to validate four fields on a form. If the person filling out the form wishes to be contacted by a sales person they have to choose a month, day, time range, and a preferred method. The person filling out the form will get an error message if they want to be contacted to soon. If it’s before noon today then the earliest that we can contact them is tomorrow after noon. If it’s after noon then the earliest we can contact them is in two days. Can anyone tell me why this isn’t working and how to fix it if possible.
[Code]
x=document.forms.Contact
strAlert=””
submitOK=”True”
if(x.drpContactMonth.value==”NA”&&x.drpContactDay.value==”NA”&&x.drpContactTime.value==”NA”&&x.drpContactMethod.value==”NA”){
}
else if(x.drpContactMonth.value==”NA”||x.drpContactDay.value==”NA”||
+ x.drpContactTime.value==”NA”||x.drpContactMethod.value==”NA”){
strAlert=strAlert + “You must fill in all contact fields if you wish to be contacted.” + CRLF()
submitOK=”False”
}
else if(x.drpContactMonth.value!=”NA”&&x.drpContactDay.value!=”NA”&&
+ x.drpContactTime.value!=”NA”&&x.drpContactMethod.value!=”NA”){
var strTodaysDate = new Date()
var strTodaysMonth = strTodaysDate.getMonth()
var strTodaysDay = strTodaysDate.getDate()
var strTodaysYear = strTodaysDate.getFullYear()
var strHour = <% Response.Write strHour %>
var strContactMonth = x.drpContactMonth.value – 1
var strContactDay = x.drpContactDay.value
var strContactYear = strTodaysYear
if(strContactMonth<strTodaysMonth){
strContactYear = strContactYear + 1
}
else if(strContactDay<strTodaysDay&&strContactMonth<strTodaysMonth){
strContactYear = strContactYear + 1
}
else if(strContactDay<strTodaysDay&&strContactMonth==strTodaysMonth){
strContactYear = strContactYear + 1
}
else if(strContactMonth==strTodaysMonth){
if(strContactDay==strTodaysDay&&strHour<12){
if(x.drpContactTime.value==”9am-11am”||x.drpContactTime.value==”11am-1pm”){
strAlert=strAlert + “If you want to be contacted at that time then you will need to give us 2 days or more.” + CRLF()
submitOK=”False”
}
else if(x.drpContactTime.value==”1pm-3pm”||x.drpContactTime.value==”3pm-5pm”||x.drpContactTime.value==”5pm-7pm”||x.drpContactTime.value==”7pm-10pm”){
strAlert=strAlert + “If you want to be contacted at that time then you will need to change the day to tomorrow or later.” + CRLF()
submitOK=”False”
}
}
else if(strContactDay<=strTodaysDay&&strHour>11){
strAlert=strAlert + “If you want to be contacted at that time then you will need to give us 2 days or more.” + CRLF()
submitOK=”False”
}
else if(strContactDay==strTodaysDay+1&&strHour<12){
if(x.drpContactTime.value==”9am-11am”||x.drpContactTime.value==”11am-1pm”){
strAlert=strAlert + “If you want to be contacted at that time then you will need to give us 2 days or more.” + CRLF()
submitOK=”False”
}
}
else if(strContactDay<=strTodaysDay+1&&strHour>11){
strAlert=strAlert + “If you want to be contacted at that time then you will need to give us 2 days or more.” + CRLF()
submitOK=”False”
}
}