View Full Version : Resolved works perfect in IE but not in FF or Chrome

09-30-2012, 04:17 AM
Hi this works perfect in IE but it does not even raise a flag (alert) at all in FF or chrome, it totally ignores it other than IE

if ((document.FrmAdvert.txtComment.value.length > 1 && document.FrmAdvert.txtComment.value != ''))

var str=document.getElementById("txtComment").innerHTML;

alert("Duplicate Characters in a row, Please remove duplicate characters!");

var newfield = str;

//dont replace the txt for edit profile (since not new reg and content exists) just make the text the old text so they can correct it

// str.replace(/(.)\1{3,}/gi,"wrong content");



return (false);

}//close if test

}//close if value

Logic Ali
09-30-2012, 05:03 AM
var str=document.getElementById("txtComment").innerHTML;

Without seeing the associated markup, I'm guessing that you're calling document.getElementById on an element that doesn't have an ID. Assuming you mean document.FrmAdvert.txtComment (which is poor addressing in itself) then you should be referencing the .value property.

09-30-2012, 05:40 AM
Hi, thanks for the reply, it does have an id..

here is the form call

<form action="<?php echo $LINK_ROOT?>/xxxx_profile.php?frm=2" name="FrmAdvert" method="post" enctype='multipart/form-data'>

and the textarea

<textarea class="inputl" rows="8" id="txtComment" name="txtComment" cols="59" tabindex="15"
onKeyDown="textCounter(this.form.txtComment,this.form.remLentext);" onKeyUp="textCounter(this.form.txtComment,this.form.remLentext);"><?=stripslashes($comment)?></textarea>

I read that FF does not support innerText but does support innerHTML so why would it not even flag it, it flags ========== big time in IE

The thing is if it would just flag it im not changing the text value of the field due to this being an edit and not a new registration, so if it would just flag it and refocus i would be fine with that.

09-30-2012, 08:30 AM
ok got it, thanks logic ali you were on the money with the .value

strange how it will accept innerHTML as the var input for IE but not for FF and chrome.

I just changed this one line

var str=document.getElementById("txtComment").value;

and it works in all browsers , i left the tail end innerHTML alone just changed this var load.