HERE is a portion of my code. I have a form that users will be entering information into. I want to check to make sure that all appropriate fields have entries. If that is true, then I want the page to redirect to another page. I'm not sure if you can use redirect in Javascript. I usually write in VBScript. If you can not use redirect, can you use location.replace? The error message that I am receiving with Location.replace is "Location is undefined".
<SCRIPT LANGUAGE=JavaScript>
<!--
var blnValidSubmission = Boolean('true'), strErrorMessage = '';
function fnValidateSubmission(){
blnValidSubmission = true;
strErrorMessage = '';
fnCheckRequired(frmAgent.businessname.value, 'BUSINESS NAME MUST BE ENTERED');
fnCheckRequired(frmAgent.email.value, 'EMAIL ADDRESS MUST BE ENTERED');
fnCheckRequired(frmAgent.paddress.value, 'PHYSICAL ADDRESS MUST BE ENTERED');
fnCheckRequired(frmAgent.pcity.value, 'PHYSICAL CITY MUST BE ENTERED');
fnCheckRequired(frmAgent.pstate.value, 'PHYSICAL STATE MUST BE ENTERED');
fnCheckRequired(frmAgent.pzip.value, 'PHYSICAL ZIP MUST BE ENTERED');
fnCheckRequired(frmAgent.maddress.value, 'MAILING ADDRESS MUST BE ENTERED');
fnCheckRequired(frmAgent.mcity.value, 'MAILING CITY MUST BE ENTERED');
fnCheckRequired(frmAgent.mstate.value, 'MAILING STATE MUST BE ENTERED');
fnCheckRequired(frmAgent.mzip.value, 'MAILING ZIP MUST BE ENTERED');
fnCheckRequired(frmAgent.taxid.value, 'FEDERAL TAX ID MUST BE ENTERED');
fnCheckRequired(frmAgent.owner.value, 'OWNER MUST BE ENTERED');
fnCheckRequired(frmAgent.contact.value, 'CONTACT MUST BE ENTERED');
fnCheckRequired(frmAgent.phone.value, 'PHONE NUMBER MUST BE ENTERED');
fnCheckRequired(frmAgent.fax.value, 'FAX NUMBER MUST BE ENTERED');
fnCheckRequired(frmAgent.sales.value, 'SALES PERSON MUST BE ENTERED');
fnCheckNum(frmAgent.pzip.value, 5, 'PHYSICAL ZIP MUST BE FIVE CHARACTERS AND ALL NUMERIC');
fnCheckNum(frmAgent.mzip.value, 5, 'MAILING ZIP MUST BE FIVE CHARACTERS AND ALL NUMERIC');
fnCheckNum(frmAgent.phone.value, 10, 'PHONE NUMBER MUST BE TEN CHARACTERS AND ALL NUMERIC');
fnCheckNum(frmAgent.fax.value, 10, 'FAX NUMBER MUST BE TEN CHARACTERS AND ALL NUMERIC');
if (blnValidSubmission){
Location.Replace("addagentdeposit.asp"
}
else{
alert(strErrorMessage);
}
}
function fnCheckRequired(strInputValue, strErrorInput){
if (blnValidSubmission){
if (strInputValue.replace(/^\W+$/, '') == ''){
blnValidSubmission = false;
strErrorMessage = strErrorInput;
}
}
}
function fnCheckNum(strInputValue, intRequiredLength, strErrorInput){
if (strInputValue.replace(/^\W+$/, '').length > 0){
if ((strInputValue.replace(/^\W+$/, '').length !== intRequiredLength) || (isNaN(strInputValue))){
blnValidSubmission = false;
strErrorMessage = strErrorInput;
}
}
}
// -->
</SCRIPT>
Thanks,
Arayforu
<SCRIPT LANGUAGE=JavaScript>
<!--
var blnValidSubmission = Boolean('true'), strErrorMessage = '';
function fnValidateSubmission(){
blnValidSubmission = true;
strErrorMessage = '';
fnCheckRequired(frmAgent.businessname.value, 'BUSINESS NAME MUST BE ENTERED');
fnCheckRequired(frmAgent.email.value, 'EMAIL ADDRESS MUST BE ENTERED');
fnCheckRequired(frmAgent.paddress.value, 'PHYSICAL ADDRESS MUST BE ENTERED');
fnCheckRequired(frmAgent.pcity.value, 'PHYSICAL CITY MUST BE ENTERED');
fnCheckRequired(frmAgent.pstate.value, 'PHYSICAL STATE MUST BE ENTERED');
fnCheckRequired(frmAgent.pzip.value, 'PHYSICAL ZIP MUST BE ENTERED');
fnCheckRequired(frmAgent.maddress.value, 'MAILING ADDRESS MUST BE ENTERED');
fnCheckRequired(frmAgent.mcity.value, 'MAILING CITY MUST BE ENTERED');
fnCheckRequired(frmAgent.mstate.value, 'MAILING STATE MUST BE ENTERED');
fnCheckRequired(frmAgent.mzip.value, 'MAILING ZIP MUST BE ENTERED');
fnCheckRequired(frmAgent.taxid.value, 'FEDERAL TAX ID MUST BE ENTERED');
fnCheckRequired(frmAgent.owner.value, 'OWNER MUST BE ENTERED');
fnCheckRequired(frmAgent.contact.value, 'CONTACT MUST BE ENTERED');
fnCheckRequired(frmAgent.phone.value, 'PHONE NUMBER MUST BE ENTERED');
fnCheckRequired(frmAgent.fax.value, 'FAX NUMBER MUST BE ENTERED');
fnCheckRequired(frmAgent.sales.value, 'SALES PERSON MUST BE ENTERED');
fnCheckNum(frmAgent.pzip.value, 5, 'PHYSICAL ZIP MUST BE FIVE CHARACTERS AND ALL NUMERIC');
fnCheckNum(frmAgent.mzip.value, 5, 'MAILING ZIP MUST BE FIVE CHARACTERS AND ALL NUMERIC');
fnCheckNum(frmAgent.phone.value, 10, 'PHONE NUMBER MUST BE TEN CHARACTERS AND ALL NUMERIC');
fnCheckNum(frmAgent.fax.value, 10, 'FAX NUMBER MUST BE TEN CHARACTERS AND ALL NUMERIC');
if (blnValidSubmission){
Location.Replace("addagentdeposit.asp"
}
else{
alert(strErrorMessage);
}
}
function fnCheckRequired(strInputValue, strErrorInput){
if (blnValidSubmission){
if (strInputValue.replace(/^\W+$/, '') == ''){
blnValidSubmission = false;
strErrorMessage = strErrorInput;
}
}
}
function fnCheckNum(strInputValue, intRequiredLength, strErrorInput){
if (strInputValue.replace(/^\W+$/, '').length > 0){
if ((strInputValue.replace(/^\W+$/, '').length !== intRequiredLength) || (isNaN(strInputValue))){
blnValidSubmission = false;
strErrorMessage = strErrorInput;
}
}
}
// -->
</SCRIPT>
Thanks,
Arayforu