Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with location.replace OR redirect 1

Status
Not open for further replies.

arayforu

Programmer
Apr 30, 2003
4
US
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(&quot;addagentdeposit.asp&quot;)
}
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
 
When I execute the page in internet explorer, I am still getting error &quot;'Location' is undefined.
 
Mark,

Thank you so much! That was it exactly!

Ashley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top