GT3_fiend
07-18-2002, 03:24 PM
ok this should be simple enuff( but me me it doesnt seem to be b/c i dont usually deal w/.js beyond rollovers) i need to rig a script that will return an alert box if some one enters the current month and year or anytime previous to that;
what i have to work with is this
RightNow=new Date();
var themonth;
var month=RightNow.getMonth()+1;
var date=RightNow.getDate();
var year=RightNow.getYear();
var day=RightNow.getDay();
if (year==100){year= 2000;}
if (year==101){year= 2001;}
if (year==102){year= 2002;}
if (year==103){year= 2003;}
if (year==104){year= 2004;}
if (year==105){year= 2005;}
function checkFields()
{
form = document.forms[0]
for (i=0;i<form.length;i++)
{
thisfield = form.elements[i]
if (thisfield.name.indexOf('ponumber') != -1)
{
if(thisfield.value == "")
{
alert("you must enter a PO number for this order")
thisfield.focus()
return false
}
}
if (thisfield.name.indexOf('shipacct') != -1)
{
if(thisfield.value=="manualaccount")
{
if(form.elements[i+1].value == "")
{
alert("you must enter an account number for this order")
form.elements[i+1].focus()
return false
}
}
}
if (thisfield.name.indexOf('cmbTerms') != -1)
{
if(thisfield.value=="")
{
alert("you must choose your payment terms")
return false
}
if(thisfield.value.match(/visa/i) != null || thisfield.value.match(/cc/i) != null || thisfield.value.match(/credit/i) != null || thisfield.value.match(/mastercard/i) != null || thisfield.value.match(/discover/i) != null || thisfield.value.match(/american express/i) != null || thisfield.value.match(/amex/i) != null)
{
if (form.elements[i+1].value == "")
{
alert("you must choose a credit card type")
form.elements[i+1].focus()
return false
}
if (form.elements[i+2].value == "")
{
alert("you must enter the name that appears on this card")
form.elements[i+2].focus()
return false
}
if (form.elements[i+3].value == "00")
{
alert("you must choose an expiration month")
form.elements[i+3].focus()
return false
}
if (form.elements[i+4].value == "00")
{
alert("you must choose an expiration year")
form.elements[i+4].focus()
return false
}
if (form.elements[i+5].value == "" || form.elements[i+5].value.length < 15)
{
alert("you must enter the complete credit card number")
form.elements[i+5].focus()
return false
}
}
}
}
return true
}
can this be adjusted to includethat kind of funtion ; or does the whole thing need to be re-written? i am a newbie so please go easy on me. thx
what i have to work with is this
RightNow=new Date();
var themonth;
var month=RightNow.getMonth()+1;
var date=RightNow.getDate();
var year=RightNow.getYear();
var day=RightNow.getDay();
if (year==100){year= 2000;}
if (year==101){year= 2001;}
if (year==102){year= 2002;}
if (year==103){year= 2003;}
if (year==104){year= 2004;}
if (year==105){year= 2005;}
function checkFields()
{
form = document.forms[0]
for (i=0;i<form.length;i++)
{
thisfield = form.elements[i]
if (thisfield.name.indexOf('ponumber') != -1)
{
if(thisfield.value == "")
{
alert("you must enter a PO number for this order")
thisfield.focus()
return false
}
}
if (thisfield.name.indexOf('shipacct') != -1)
{
if(thisfield.value=="manualaccount")
{
if(form.elements[i+1].value == "")
{
alert("you must enter an account number for this order")
form.elements[i+1].focus()
return false
}
}
}
if (thisfield.name.indexOf('cmbTerms') != -1)
{
if(thisfield.value=="")
{
alert("you must choose your payment terms")
return false
}
if(thisfield.value.match(/visa/i) != null || thisfield.value.match(/cc/i) != null || thisfield.value.match(/credit/i) != null || thisfield.value.match(/mastercard/i) != null || thisfield.value.match(/discover/i) != null || thisfield.value.match(/american express/i) != null || thisfield.value.match(/amex/i) != null)
{
if (form.elements[i+1].value == "")
{
alert("you must choose a credit card type")
form.elements[i+1].focus()
return false
}
if (form.elements[i+2].value == "")
{
alert("you must enter the name that appears on this card")
form.elements[i+2].focus()
return false
}
if (form.elements[i+3].value == "00")
{
alert("you must choose an expiration month")
form.elements[i+3].focus()
return false
}
if (form.elements[i+4].value == "00")
{
alert("you must choose an expiration year")
form.elements[i+4].focus()
return false
}
if (form.elements[i+5].value == "" || form.elements[i+5].value.length < 15)
{
alert("you must enter the complete credit card number")
form.elements[i+5].focus()
return false
}
}
}
}
return true
}
can this be adjusted to includethat kind of funtion ; or does the whole thing need to be re-written? i am a newbie so please go easy on me. thx