0

Our Company uses a closed sourced shopping cart system for its e-comreace web site. The check out page is generated by a cgi script that I can not modify. I would like to replace the form validation script it generates with my own. The script I am trying to replace is the second script in the document. I have inserted the following script in the footer section:

document.body.getElementsByTagName("SCRIPT")[1].innerHTML = "New Validation Function Here";

however when the validation function is called the old one executes, not my new function.

Where am I going wrong? Is there a better way?

Chris

2 Answers 2

5

You probably have a better chance at replacing the validation function in the global scope.

<!-- Old script file -->
<script>

function doValidate(value) {
 return true;
}
</script>

<!-- New script file -->
<script>
function doValidateNew(value) {
 return false;
}
window.doValidate = doValidateNew;
</script>
Sign up to request clarification or add additional context in comments.

Comments

1

You don't need to replace the old SCRIPT tag that was already executed.

The validation function is just a value, and the function name is a variable, so you could just do this:

<script>

oldValidationFunctionName = function(param1, param2, whatever) {
    // the new function body here...
 }

</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.