/    Sign up×
Community /Pin to ProfileBookmark

Java script IE problem

Hi Could you please tell me why my script is not running on IE6/IE7/safari. it works fine on localhost but when i put this file on a host it wont work. Here is my html code, works good on firefox

<body>

<SCRIPT TYPE=”text/javascript”>

function validateOnSubmit() {
var elem;
var errs=0;

if (!validateFName(document.forms.anthology.contFName, ‘inf_FName’)) errs += 1;
if(!validateMName(document.forms.anthology.contMName, ‘inf_MName’)) errs += 1;

if (errs>1) alert(‘There are fields which need correction before sending’);
if (errs==1) alert(‘There is a field which needs correction before sending’);

return (errs==0);
};
</SCRIPT>

<table class=”formtab” summary=”Demonstration form”>
<tr>
<td width=”80″ style=”width: 5em”><label for=”from”>Section Title</label></td>
<td width=”210″><input type=”text” name=”SectionTitle” id=”SectionTitle” size=”35″ maxlength=”50″
onchange=”validateSectionTitle(this, ‘inf_SectionTitle’, true);” /></td>
<td width=”142″ id=”inf_SectionTitle”>Required</td>
</tr>

</table>
<label><br />
</label>
</body>


—————-

RELATED .JS CODE
—————-

function validateSectionTitle(valfield,
infofield) {
var stat = commonCheck (valfield, infofield,true);
if (stat != proceed) return stat;

msg (infofield, “warn”, “”);
return true;
}

function commonCheck(valfield, infofield, required)
{

if (!document.getElementById)

return true; var elem = document.getElementById(infofield);
if (!elem.firstChild) return true;
if (elem.firstChild.nodeType != node_text) return true;
if (emptyString.test(valfield.value)) {
if (required) {
msg (infofield, “error”, “ERROR: required”);
setfocus(valfield);
return false;
}

else {
msg (infofield, “warn”, “”);
return true;
}
}
return proceed;
}

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 06.2008 — This doesn't work in any browser; [I]node_text[/I] is undefined.

Use:if (elem.firstChild.nodeType != <a href="http://developer.mozilla.org/En/DOM/Element.nodeType">Node.TEXT_NODE</a>) return true;
For IE also see: http://www.safalra.com/web-design/javascript/dom-node-type-constants/
×

Success!

Help @desiinusa123 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...