/    Sign up×
Community /Pin to ProfileBookmark

Dynamically remove javascript

I have put two iContact signup forms on the same page. One in the sidebar and one in the middle of the page.

When I submit the one in the middle of the page, it gives me an error. The following code is triggering the error.

[CODE]
<script type=”text/javascript”>

var icpForm64527 = document.getElementById(‘icpsignup64527’);

function verifyRequired64527() {
if (icpForm64527[“fields_email”].value == “”) {
icpForm64527[“fields_email”].focus();
alert(“The Email field is required.”);
return false;
}

return true;
}
</script>[/CODE]

The reason is because it is looking for a required email field from the sidebar form. It is reading both forms as the same. iContact support told me this could not be fixed.

So I need one of two solutions.

A way for the error code to work properly with both forms.

The other option which I think is simpler is to remove the javascript validation code. I do not want to do this manually for each form.

[B]Is there a way in javascript to dynamically remove the block of javascript shown above anytime it appears on a page?[/B]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JunkMaleOct 26.2011 — have you tried nulling the function?

[code=html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Killer Function</title>
<script>
<!--

function thisDontExist(){

alert("I'M ALIVE!");
}


function killTheOtherFunction(){

thisDontExist = null;

}

thisDontExist();
killTheOtherFunction();
try{
thisDontExist();
}catch(e){
alert("Oops! "+e);
}
//-->
</script>
</head>

<body>
</body>
</html>[/code]
×

Success!

Help @jagwebby spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...