Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,376
    Thanks
    263
    Thanked 32 Times in 31 Posts

    works perfect in IE but not in FF or Chrome

    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

    Code:
    
        if ((document.FrmAdvert.txtComment.value.length > 1 && document.FrmAdvert.txtComment.value != ''))
          {
     
           var str=document.getElementById("txtComment").innerHTML;
           
           if(/(.)\1{2,}/i.test(str)) 
            {
            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");
    
            document.getElementById("txtComment").innerHTML=newfield;
    
            document.FrmAdvert.txtComment.focus();
    
            return (false);
    
             }//close if test
    
          }//close if value
    Last edited by durangod; 09-30-2012 at 07:31 AM.

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by durangod View Post
    Code:
           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.

  • Users who have thanked Logic Ali for this post:

    durangod (09-30-2012)

  • #3
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,376
    Thanks
    263
    Thanked 32 Times in 31 Posts
    Hi, thanks for the reply, it does have an id..



    Code:
    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.
    Last edited by durangod; 09-30-2012 at 04:46 AM.

  • #4
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,376
    Thanks
    263
    Thanked 32 Times in 31 Posts
    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

    Code:
    var str=document.getElementById("txtComment").value;
    and it works in all browsers , i left the tail end innerHTML alone just changed this var load.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •